当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::newInstance方法代码示例

本文整理汇总了PHP中Item::newInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::newInstance方法的具体用法?PHP Item::newInstance怎么用?PHP Item::newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Item的用法示例。


在下文中一共展示了Item::newInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'logout':
             // unset only the required parameters in Session
             Session::newInstance()->_drop('adminId');
             Session::newInstance()->_drop('adminUserName');
             Session::newInstance()->_drop('adminName');
             Session::newInstance()->_drop('adminEmail');
             Session::newInstance()->_drop('adminLocale');
             Cookie::newInstance()->pop('oc_adminId');
             Cookie::newInstance()->pop('oc_adminSecret');
             Cookie::newInstance()->pop('oc_adminLocale');
             Cookie::newInstance()->set();
             $this->redirectTo(osc_admin_base_url(true));
             break;
         default:
             //default dashboard page (main page at oc-admin)
             $this->_exportVariableToView("numUsers", User::newInstance()->count());
             $this->_exportVariableToView("numAdmins", Admin::newInstance()->count());
             $this->_exportVariableToView("numItems", Item::newInstance()->count());
             $this->_exportVariableToView("numItemsSpam", Item::newInstance()->totalItems(null, 'SPAM'));
             $this->_exportVariableToView("numItemsBlock", Item::newInstance()->totalItems(null, 'DISABLED'));
             $this->_exportVariableToView("numItemsInactive", Item::newInstance()->totalItems(null, 'INACTIVE'));
             $this->_exportVariableToView("numItemsPerCategory", osc_get_non_empty_categories());
             $this->_exportVariableToView("newsList", osc_listNews());
             $this->_exportVariableToView("comments", ItemComment::newInstance()->getLastComments(5));
             //calling the view...
             $this->doView('main/index.php');
     }
 }
开发者ID:randomecho,项目名称:OSClass,代码行数:31,代码来源:main.php

示例2: update_cat_stats

function update_cat_stats()
{
    $categoryTotal = array();
    $categoryTree = array();
    $aCategories = Category::newInstance()->listAll(false);
    // append root categories and get the number of items of each category
    foreach ($aCategories as $category) {
        $total = Item::newInstance()->numItems($category, true, true);
        $category += array('category' => array());
        if (is_null($category['fk_i_parent_id'])) {
            $categoryTree += array($category['pk_i_id'] => $category);
        }
        $categoryTotal += array($category['pk_i_id'] => $total);
    }
    // append childs to root categories
    foreach ($aCategories as $category) {
        if (!is_null($category['fk_i_parent_id'])) {
            $categoryTree[$category['fk_i_parent_id']]['category'][] = $category;
        }
    }
    // sum the result of the subcategories and set in the parent category
    foreach ($categoryTree as $category) {
        if (count($category['category']) > 0) {
            foreach ($category['category'] as $subcategory) {
                $categoryTotal[$category['pk_i_id']] += $categoryTotal[$subcategory['pk_i_id']];
            }
        }
    }
    foreach ($categoryTotal as $k => $v) {
        CategoryStats::newInstance()->setNumItems($k, $v);
    }
}
开发者ID:acharei,项目名称:OSClass,代码行数:32,代码来源:cron.hourly.php

示例3: payment_pro_send_email

function payment_pro_send_email($email)
{
    $item = Item::newInstance()->findByPrimaryKey($email['fk_i_item_id']);
    $mPages = new Page();
    $aPage = $mPages->findByInternalName('payment_pro_email_payment');
    $locale = osc_current_user_locale();
    $content = array();
    if (isset($aPage['locale'][$locale]['s_title'])) {
        $content = $aPage['locale'][$locale];
    } else {
        $content = current($aPage['locale']);
    }
    $item_url = osc_item_url();
    $item_url = '<a href="' . $item_url . '" >' . $item_url . '</a>';
    $publish_url = osc_route_url('payment-pro-addcart', array('item' => 'PUB' . $item['fk_i_category_id'] . '-' . $item['pk_i_id']));
    $premium_url = osc_route_url('payment-pro-addcart', array('item' => 'PRM' . $item['fk_i_category_id'] . '-' . $item['pk_i_id']));
    $words = array();
    $words[] = array('{ITEM_ID}', '{CONTACT_NAME}', '{CONTACT_EMAIL}', '{WEB_URL}', '{ITEM_TITLE}', '{ITEM_URL}', '{WEB_TITLE}', '{PUBLISH_LINK}', '{PUBLISH_URL}', '{PREMIUM_LINK}', '{PREMIUM_URL}', '{START_PUBLISH_FEE}', '{END_PUBLISH_FEE}', '{START_PREMIUM_FEE}', '{END_PREMIUM_FEE}');
    $words[] = array($item['pk_i_id'], $item['s_contact_name'], $item['s_contact_email'], osc_base_url(), $item['s_title'], $item_url, osc_page_title(), '<a href="' . $publish_url . '">' . $publish_url . '</a>', $publish_url, '<a href="' . $premium_url . '">' . $premium_url . '</a>', $premium_url, '', '', '', '');
    if ($email['b_publish'] == 0) {
        $content['s_text'] = preg_replace('|{START_PUBLISH_FEE}(.*){END_PUBLISH_FEE}|', '', $content['s_text']);
    }
    if ($email['b_premium'] == 0) {
        $content['s_text'] = preg_replace('|{START_PREMIUM_FEE}(.*){END_PREMIUM_FEE}|', '', $content['s_text']);
    }
    $title = osc_apply_filter('alert_email_payment_pro_title_after', osc_mailBeauty(osc_apply_filter('email_payment_pro_title', osc_apply_filter('alert_email_payment_pro_title', $content['s_title'], $email, $item)), $words), $email, $item);
    $body = osc_apply_filter('alert_email_payment_pro_description_after', osc_mailBeauty(osc_apply_filter('email_payment_pro_description', osc_apply_filter('alert_email_payment_pro_description', $content['s_text'], $email, $item)), $words), $email, $item);
    $emailParams = array('subject' => $title, 'to' => $item['s_contact_email'], 'to_name' => $item['s_contact_name'], 'body' => $body, 'alt_body' => $body);
    osc_sendMail($emailParams);
}
开发者ID:michaelxizhou,项目名称:myeden69-original-backup,代码行数:30,代码来源:functions.php

示例4: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'change_email_confirm':
             //change email confirm
             if (Params::getParam('userId') && Params::getParam('code')) {
                 $userManager = new User();
                 $user = $userManager->findByPrimaryKey(Params::getParam('userId'));
                 if ($user['s_pass_code'] == Params::getParam('code') && $user['b_enabled'] == 1) {
                     $userEmailTmp = UserEmailTmp::newInstance()->findByPk(Params::getParam('userId'));
                     $code = osc_genRandomPassword(50);
                     $userManager->update(array('s_email' => $userEmailTmp['s_new_email']), array('pk_i_id' => $userEmailTmp['fk_i_user_id']));
                     Item::newInstance()->update(array('s_contact_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
                     ItemComment::newInstance()->update(array('s_author_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
                     Alerts::newInstance()->update(array('s_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
                     Session::newInstance()->_set('userEmail', $userEmailTmp['s_new_email']);
                     UserEmailTmp::newInstance()->delete(array('s_new_email' => $userEmailTmp['s_new_email']));
                     osc_add_flash_ok_message(_m('Your email has been changed successfully'));
                     $this->redirectTo(osc_user_profile_url());
                 } else {
                     osc_add_flash_error_message(_m('Sorry, the link is not valid'));
                     $this->redirectTo(osc_base_url());
                 }
             } else {
                 osc_add_flash_error_message(_m('Sorry, the link is not valid'));
                 $this->redirectTo(osc_base_url());
             }
             break;
         case 'activate_alert':
             $email = Params::getParam('email');
             $secret = Params::getParam('secret');
             $result = 0;
             if ($email != '' && $secret != '') {
                 $result = Alerts::newInstance()->activate($email, $secret);
             }
             if ($result == 1) {
                 osc_add_flash_ok_message(_m('Alert activated'));
             } else {
                 osc_add_flash_error_message(_m('Ops! There was a problem trying to activate alert. Please contact the administrator'));
             }
             $this->redirectTo(osc_base_url(true));
             break;
         case 'unsub_alert':
             $email = Params::getParam('email');
             $secret = Params::getParam('secret');
             if ($email != '' && $secret != '') {
                 Alerts::newInstance()->delete(array('s_email' => $email, 'S_secret' => $secret));
                 osc_add_flash_ok_message(_m('Unsubscribed correctly'));
             } else {
                 osc_add_flash_error_message(_m('Ops! There was a problem trying to unsubscribe you. Please contact the administrator'));
             }
             $this->redirectTo(osc_base_url());
             break;
         default:
             $this->redirectTo(osc_user_login_url());
             break;
     }
 }
开发者ID:nsswaga,项目名称:OSClass,代码行数:58,代码来源:user-non-secure.php

示例5: digitalgoods_item_edit

function digitalgoods_item_edit($catId = null, $item_id = null)
{
    if (osc_is_this_category('digitalgoods', $catId)) {
        $dg_files = DGModel::newInstance()->getFilesFromItem($item_id);
        $dg_item = Item::newInstance()->findByPrimaryKey($item_id);
        $secret = $dg_item['s_secret'];
        unset($dg_item);
        require_once 'item_edit.php';
    }
}
开发者ID:syedfiraat4,项目名称:bikade.com,代码行数:10,代码来源:index.php

示例6: processData

 private function processData($comments)
 {
     if (!empty($comments)) {
         $csrf_token_url = osc_csrf_token_url();
         foreach ($comments as $aRow) {
             $row = array();
             $options = array();
             $options_more = array();
             View::newInstance()->_exportVariableToView('item', Item::newInstance()->findByPrimaryKey($aRow['fk_i_item_id']));
             if ($aRow['b_enabled']) {
                 $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=DISABLE">' . __('Block') . '</a>';
             } else {
                 $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=ENABLE">' . __('Unblock') . '</a>';
             }
             $options_more[] = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" href="' . osc_admin_base_url(true) . '?page=comments&amp;action=delete&amp;id=' . $aRow['pk_i_id'] . '" id="dt_link_delete">' . __('Delete') . '</a>';
             $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=comment_edit&amp;id=' . $aRow['pk_i_id'] . '" id="dt_link_edit">' . __('Edit') . '</a>';
             if ($aRow['b_active']) {
                 $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=INACTIVE">' . __('Deactivate') . '</a>';
             } else {
                 $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=ACTIVE">' . __('Activate') . '</a>';
             }
             // more actions
             $moreOptions = '<li class="show-more">' . PHP_EOL . '<a href="#" class="show-more-trigger">' . __('Show more') . '...</a>' . PHP_EOL . '<ul>' . PHP_EOL;
             foreach ($options_more as $actual) {
                 $moreOptions .= '<li>' . $actual . "</li>" . PHP_EOL;
             }
             $moreOptions .= '</ul>' . PHP_EOL . '</li>' . PHP_EOL;
             // create list of actions
             $auxOptions = '<ul>' . PHP_EOL;
             foreach ($options as $actual) {
                 $auxOptions .= '<li>' . $actual . '</li>' . PHP_EOL;
             }
             $auxOptions .= $moreOptions;
             $auxOptions .= '</ul>' . PHP_EOL;
             $actions = '<div class="actions">' . $auxOptions . '</div>' . PHP_EOL;
             $status = $this->get_row_status($aRow);
             $row['status-border'] = '';
             $row['status'] = $status['text'];
             $row['bulkactions'] = '<input type="checkbox" name="id[]" value="' . $aRow['pk_i_id'] . '" />';
             if (empty($aRow['s_author_name'])) {
                 $user = User::newInstance()->findByPrimaryKey($aRow['fk_i_user_id']);
                 $aRow['s_author_name'] = $user['s_email'];
             }
             $row['author'] = $aRow['s_author_name'] . ' (<a target="_blank" href="' . osc_item_url() . '">' . osc_item_title() . '</a>)' . $actions;
             $row['comment'] = $aRow['s_body'];
             $row['date'] = osc_format_date($aRow['dt_pub_date']);
             $row = osc_apply_filter('comments_processing_row', $row, $aRow);
             $this->addRow($row);
             $this->rawRows[] = $aRow;
         }
     }
 }
开发者ID:oanav,项目名称:closetshare,代码行数:52,代码来源:CommentsDataTable.php

示例7: insert_geo_location

function insert_geo_location($catId, $itemId)
{
    $aItem = Item::newInstance()->findByPrimaryKey($itemId);
    $sAddress = isset($aItem['s_address']) ? $aItem['s_address'] : '';
    $sRegion = isset($aItem['s_region']) ? $aItem['s_region'] : '';
    $sCity = isset($aItem['s_city']) ? $aItem['s_city'] : '';
    $address = sprintf('%s, %s %s', $sAddress, $sRegion, $sCity);
    $response = osc_file_get_contents(sprintf('http://maps.google.com/maps/geo?q=%s&output=json&sensor=false', urlencode($address)));
    $jsonResponse = json_decode($response);
    if (isset($jsonResponse->Placemark) && count($jsonResponse->Placemark[0]) > 0) {
        $coord = $jsonResponse->Placemark[0]->Point->coordinates;
        ItemLocation::newInstance()->update(array('d_coord_lat' => $coord[1], 'd_coord_long' => $coord[0]), array('fk_i_item_id' => $itemId));
    }
}
开发者ID:nsswaga,项目名称:OSClass,代码行数:14,代码来源:index.php

示例8: insert_geo_location

function insert_geo_location($item)
{
    $itemId = $item['pk_i_id'];
    $aItem = Item::newInstance()->findByPrimaryKey($itemId);
    $sAddress = isset($aItem['s_address']) ? $aItem['s_address'] : '';
    $sCity = isset($aItem['s_city']) ? $aItem['s_city'] : '';
    $sRegion = isset($aItem['s_region']) ? $aItem['s_region'] : '';
    $sCountry = isset($aItem['s_country']) ? $aItem['s_country'] : '';
    $address = sprintf('%s, %s, %s, %s', $sAddress, $sCity, $sRegion, $sCountry);
    $response = osc_file_get_contents(sprintf('https://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false', urlencode($address)));
    $jsonResponse = json_decode($response);
    if (isset($jsonResponse->results[0]->geometry->location) && count($jsonResponse->results[0]->geometry->location) > 0) {
        $location = $jsonResponse->results[0]->geometry->location;
        $lat = $location->lat;
        $lng = $location->lng;
        ItemLocation::newInstance()->update(array('d_coord_lat' => $lat, 'd_coord_long' => $lng), array('fk_i_item_id' => $itemId));
    }
}
开发者ID:keramist,项目名称:Osclass,代码行数:18,代码来源:index.php

示例9: tableReported

 public function tableReported($params)
 {
     $this->addTableHeaderReported();
     $this->mSearch = new Search(true);
     $this->getDBParams($params);
     // only some fields can be ordered
     $direction = Params::getParam('direction');
     $arrayDirection = array('desc', 'asc');
     if (!in_array($direction, $arrayDirection)) {
         Params::setParam('direction', 'desc');
         $direction = 'desc';
     }
     $sort = Params::getParam('sort');
     $arraySortColumns = array('spam' => 'i_num_spam', 'bad' => 'i_num_bad_classified', 'rep' => 'i_num_repeated', 'off' => 'i_num_offensive', 'exp' => 'i_num_expired', 'date' => 'dt_pub_date');
     // column sort
     if (!key_exists($sort, $arraySortColumns)) {
         $sort = 'dt_pub_date';
         $this->mSearch->addHaving('i_num_spam > 0 OR i_num_bad_classified > 0 OR i_num_repeated > 0 OR i_num_offensive > 0 OR i_num_expired > 0');
     } else {
         $sort = $arraySortColumns[$sort];
         if ($sort != 'dt_pub_date') {
             $this->mSearch->addHaving($sort . ' > 0');
         } else {
             $this->mSearch->addHaving('i_num_spam > 0 OR i_num_bad_classified > 0 OR i_num_repeated > 0 OR i_num_offensive > 0 OR i_num_expired > 0');
         }
     }
     $this->mSearch->order($sort, $direction);
     $this->mSearch->addTable(sprintf("%st_item_stats s", DB_TABLE_PREFIX));
     $this->mSearch->addField('SUM(s.`i_num_spam`) as i_num_spam');
     $this->mSearch->addField('SUM(s.`i_num_bad_classified`) as i_num_bad_classified');
     $this->mSearch->addField('SUM(s.`i_num_repeated`) as i_num_repeated');
     $this->mSearch->addField('SUM(s.`i_num_offensive`) as i_num_offensive');
     $this->mSearch->addField('SUM(s.`i_num_expired`) as i_num_expired');
     // having
     $this->mSearch->addConditions(sprintf(" %st_item.pk_i_id ", DB_TABLE_PREFIX));
     $this->mSearch->addConditions(sprintf(" %st_item.pk_i_id = s.fk_i_item_id", DB_TABLE_PREFIX));
     $this->mSearch->addGroupBy(sprintf(" %st_item.pk_i_id ", DB_TABLE_PREFIX));
     // do Search
     $this->processDataReported(Item::newInstance()->extendCategoryName($this->mSearch->doSearch(true)));
     $this->totalFiltered = $this->mSearch->countAll();
     $this->total = $this->mSearch->count();
     return $this->getData();
 }
开发者ID:jmcclenon,项目名称:Osclass,代码行数:43,代码来源:ItemsDataTable.php

示例10: __construct

 function __construct($params)
 {
     $this->mSearch = new Search(true);
     $this->_get = $params;
     $this->getDBParams();
     $this->mSearch->limit($this->start, $this->limit);
     // only some fields can be ordered
     $this->mSearch->order($this->order_by['column_name'], $this->order_by['type'], $this->order_by['table_name']);
     if (Params::getParam('catId') != '') {
         $this->mSearch->addCategory(Params::getParam('catId'));
     }
     if ($this->search) {
         $this->mSearch->addPattern($this->search);
     }
     // do Search
     $list_items = $this->mSearch->doSearch(true);
     $this->items = Item::newInstance()->extendCategoryName($list_items);
     $this->total_filtered = $this->mSearch->countAll();
     $this->total = $this->mSearch->count();
     $this->toDatatablesFormat();
     $this->dumpToDatatables();
 }
开发者ID:randomecho,项目名称:OSClass,代码行数:22,代码来源:items_processing.php

示例11: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'logout':
             // unset only the required parameters in Session
             $this->logout();
             $this->redirectTo(osc_admin_base_url(true));
             break;
         default:
             //default dashboard page (main page at oc-admin)
             $this->_exportVariableToView("numItemsPerCategory", osc_get_non_empty_categories());
             $this->_exportVariableToView("numUsers", User::newInstance()->count());
             $this->_exportVariableToView("numItems", Item::newInstance()->count());
             $this->_exportVariableToView('newsList', osc_listNews());
             $this->_exportVariableToView('twitterRSS', osc_latestTweets());
             // stats
             $items = array();
             $stats_items = Stats::newInstance()->new_items_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d") - 10, date("Y"))), 'day');
             for ($k = 10; $k >= 0; $k--) {
                 $items[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))] = 0;
             }
             foreach ($stats_items as $item) {
                 $items[$item['d_date']] = $item['num'];
             }
             $users = array();
             $stats_users = Stats::newInstance()->new_users_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d") - 10, date("Y"))), 'day');
             for ($k = 10; $k >= 0; $k--) {
                 $users[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))] = 0;
             }
             foreach ($stats_users as $user) {
                 $users[$user['d_date']] = $user['num'];
             }
             $this->_exportVariableToView("item_stats", $items);
             $this->_exportVariableToView("user_stats", $users);
             //calling the view...
             $this->doView('main/index.php');
     }
 }
开发者ID:semul,项目名称:Osclass,代码行数:38,代码来源:main.php

示例12: deleteUser

 /**
  * Delete an user given its id
  *
  * @access public
  * @since unknown
  * @param int $id
  * @return bool
  */
 public function deleteUser($id = null)
 {
     if ($id != null) {
         osc_run_hook('delete_user', $id);
         $this->dao->select('pk_i_id, fk_i_category_id');
         $this->dao->from(DB_TABLE_PREFIX . "t_item");
         $this->dao->where('fk_i_user_id', $id);
         $result = $this->dao->get();
         $items = $result->result();
         $itemManager = Item::newInstance();
         foreach ($items as $item) {
             $itemManager->deleteByPrimaryKey($item['pk_i_id']);
         }
         ItemComment::newInstance()->delete(array('fk_i_user_id' => $id));
         $this->dao->delete(DB_TABLE_PREFIX . 't_user_email_tmp', array('fk_i_user_id' => $id));
         $this->dao->delete(DB_TABLE_PREFIX . 't_user_description', array('fk_i_user_id' => $id));
         $this->dao->delete(DB_TABLE_PREFIX . 't_alerts', array('fk_i_user_id' => $id));
         return $this->dao->delete($this->getTableName(), array('pk_i_id' => $id));
     }
     return false;
 }
开发者ID:ranjithinnergys,项目名称:OSClass,代码行数:29,代码来源:User.php

示例13: osc_user_phone

    /* if (osc_user_phone() != '') { ?>
       <div class="user-phone">
           <i class="fa fa-phone"></i>
           <span><?php echo osc_user_phone() ?></span>
       </div>
       <?php }*/
    ?>
               
                <div class="divider"></div>

                <?php 
}
?>

                <?php 
$aItems = Item::newInstance()->findByUserID(osc_item_user_id(), 0, 3);
View::newInstance()->_exportVariableToView('items', $aItems);
?>
                <div class="user-products">
                    <p><?php 
printf(__('Other products from %s', 'pop'), osc_user_name());
?>
</p>
                    <div>
                        <?php 
while (osc_has_items()) {
    if (osc_count_item_resources()) {
        osc_get_item_resources();
        ?>
                        <a class="user-item" href="<?php 
        echo osc_item_url();
开发者ID:oanav,项目名称:closetshare,代码行数:31,代码来源:item.php

示例14: osc_get_premium_meta

/**
 * Gets premium meta fields
 *
 * @return array
 */
function osc_get_premium_meta()
{
    if (!View::newInstance()->_exists('metafields')) {
        View::newInstance()->_exportVariableToView('metafields', Item::newInstance()->metaFields(osc_premium_id()));
    }
    return View::newInstance()->_get('metafields');
}
开发者ID:acharei,项目名称:OSClass,代码行数:12,代码来源:hPremium.php

示例15: edit

        function edit() {
            $aItem       = $this->data;
            $flash_error = '';

            // Sanitize
            foreach(@$aItem['title'] as $key=>$value) {
                $aItem['title'][$key] = strip_tags( trim ( $value ) );
            }

            $aItem['price']    = !is_null($aItem['price']) ? strip_tags( trim( $aItem['price'] ) ) : $aItem['price'];
            $aItem['cityArea'] = osc_sanitize_name( strip_tags( trim( $aItem['cityArea'] ) ) );
            $aItem['address']  = osc_sanitize_name( strip_tags( trim( $aItem['address'] ) ) );

            // Validate
            if ( !$this->checkAllowedExt($aItem['photos']) ) {
                $flash_error .= _m("Image with an incorrect extension.") . PHP_EOL;
            }
            if ( !$this->checkSize($aItem['photos']) ) {
                $flash_error .= _m("Image is too big. Max. size") . osc_max_size_kb() . " Kb" . PHP_EOL;
            }

            $title_message  = '';
            $td_message     = '';
            foreach(@$aItem['title'] as $key => $value) {
                if( osc_validate_text($value, 1) && osc_validate_max($value, osc_max_characters_per_title()) ) {
                    $td_message = '';
                    break;
                }

                $td_message .=
                    (!osc_validate_text($value, 1) ? _m("Title too short.") . PHP_EOL : '' ) .
                    (!osc_validate_max($value, osc_max_characters_per_title()) ? _m("Title too long.") . PHP_EOL : '' );
            }
            $flash_error .= $td_message;

            $desc_message = '';
            foreach(@$aItem['description'] as $key => $value) {
                if( osc_validate_text($value, 3) &&  osc_validate_max($value, osc_max_characters_per_description()) )  {
                    $desc_message = '';
                    break;
                }

                $desc_message .=
                    (!osc_validate_text($value, 3) ? _m("Description too short.") . PHP_EOL : '' ) .
                    (!osc_validate_max($value, osc_max_characters_per_description()) ? _m("Description too long."). PHP_EOL : '' );
            }
            $flash_error .= $desc_message;

            $flash_error .=
                ((!osc_validate_category($aItem['catId'])) ? _m("Category invalid.") . PHP_EOL : '' ) .
                ((!osc_validate_number($aItem['price'])) ? _m("Price must be a number.") . PHP_EOL : '' ) .
                ((!osc_validate_max(number_format($aItem['price'],0,'',''), 15)) ? _m("Price too long.") . PHP_EOL : '' ) .
                ((!is_null($aItem['price']) && (int)$aItem['price']<0 ) ? _m('Price must be positive number.') . PHP_EOL : '' ) .
                ((!osc_validate_text($aItem['countryName'], 3, false)) ? _m("Country too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['countryName'], 50)) ? _m("Country too long.") . PHP_EOL : '' ) .
                ((!osc_validate_text($aItem['regionName'], 2, false)) ? _m("Region too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['regionName'], 50)) ? _m("Region too long.") . PHP_EOL : '' ) .
                ((!osc_validate_text($aItem['cityName'], 2, false)) ? _m("City too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['cityName'], 50)) ? _m("City too long.") . PHP_EOL : '' ) .
                ((!osc_validate_text($aItem['cityArea'], 3, false)) ? _m("Municipality too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['cityArea'], 50)) ? _m("Municipality too long.") . PHP_EOL : '' ) .
                ((!osc_validate_text($aItem['address'], 3, false))? _m("Address too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['address'], 100)) ? _m("Address too long.") . PHP_EOL : '' );

            $_meta = Field::newInstance()->findByCategory($aItem['catId']);
            $meta = Params::getParam("meta");
            foreach($_meta as $_m) {
                $meta[$_m['pk_i_id']] = (isset($meta[$_m['pk_i_id']]))?$meta[$_m['pk_i_id']]:'';
            }
            if($meta!='' && count($meta)>0) {
                $mField = Field::newInstance();
                foreach($meta as $k => $v) {
                    if($v=='') {
                        $field = $mField->findByPrimaryKey($k);
                        if($field['b_required']==1) {
                            $flash_error .= sprintf(_m("%s field is required."), $field['s_name']) . PHP_EOL;
                        }
                    }
                }
            };

            // hook pre add or edit
            // DEPRECATED : preitem_psot will be removed in 3.4
            osc_run_hook('pre_item_post');
            osc_run_hook('pre_item_edit', $aItem);

            // Handle error
            if ($flash_error) {
                $success = $flash_error;
            } else {
                $location = array(
                    'fk_c_country_code' => $aItem['countryId'],
                    's_country'         => $aItem['countryName'],
                    'fk_i_region_id'    => $aItem['regionId'],
                    's_region'          => $aItem['regionName'],
                    'fk_i_city_id'      => $aItem['cityId'],
                    's_city'            => $aItem['cityName'],
                    's_city_area'       => $aItem['cityArea'],
                    's_address'         => $aItem['address'],
                    'd_coord_lat'       => $aItem['d_coord_lat'],
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:101,代码来源:ItemActions.php


注:本文中的Item::newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。