/** * 增加新的文章 * * @param object $data 文章的信息 * @access public * @return boolean */ public function addContent(ContentSave $data) { if (!$this->contentValidate->add($data)) { $unValidateMsg = $this->contentValidate->getErrorMessage(); return $this->setErrorMsg($unValidateMsg); } $articleObj = new \stdClass(); $articleObj->time = time(); $articleObj->userId = SC::getLoginSession()->id; try { $articleObj->autoId = $this->saveContent($data, $articleObj); $this->saveContentDetail($data, $articleObj); $this->saveArticleTags($articleObj, $data['tags']); $this->saveArticleClassify($articleObj, $data['classify']); $this->saveSeachFullText($articleObj, $data); $this->contentSaveSuccess($articleObj->autoId); $result = true; } catch (Exception $e) { $result = false; } if (!$result) { return $this->setErrorMsg(Lang::get('common.action_error')); } return true; }
public function start(Application $app) { $this->app = new AppContainer(); foreach ($this->aliases as $key => $value) { $this->app->add($value, $key)->withArgument($app); } }
/** * Set response for specific request. * * @param object|array $request * Request object or array. * @param object|array $response * Response object or array to set. */ protected function setResponse($request, $response) { $request = (object) $request; $response = (object) $response; $response->criteria = $request; $this->responseStorage->add($response); }
/** * Adds a new item that is to be cached * * @param string $key * @param mixed $data * @param bool $overwrite * @return bool */ public function add($key, $data, $overwrite = false) { if ($overwrite == false) { return $this->memcached->add($key, $data, $this->ttl()); } else { return $this->memcached->set($key, $data, $this->ttl()); } }
/** * Add debug log message * * @since 1.0 * * @param string $message */ public static function add_debug_log($message) { if (!is_object(self::$log)) { self::$log = WooCommerce_Grow_Compat::get_wc_logger(); } if (self::is_debug_enabled()) { self::$log->add('wc_grow', $message); } }
/** * the menu item * @param object $event * @return void */ function onmasteradminGetMenuContent($event) { $chemin = jApp::config()->urlengine['basePath'] . 'hfnu/admin/'; if (jAcl2::check('hfnu.admin.index')) { $event->add(new masterAdminMenuItem('hfnuthemes', jLocale::get('hfnuthemes~theme.themes'), '', 30)); $item = new masterAdminMenuItem('theme', jLocale::get('hfnuthemes~theme.themes'), jUrl::get('hfnuthemes~default:index'), 10, 'hfnuthemes'); $item->icon = $chemin . 'images/theme.png'; $event->add($item); } }
/** * the menu item * @param object $event * @return void */ function onmasteradminGetMenuContent($event) { $chemin = jApp::config()->urlengine['basePath'] . 'hfnu/admin/'; if (jAcl2::check('hfnu.admin.contact')) { $event->add(new masterAdminMenuItem('hfnucontact', 'Contact', '', 40)); $item = new masterAdminMenuItem('contact', jLocale::get('hfnucontact~contact.contact'), jUrl::get('hfnucontact~admin:index'), 100, 'hfnucontact'); $item->icon = $chemin . 'images/contact.png'; $event->add($item); } }
/** * the menu item * @param object $event * @return void */ function onmasteradminGetMenuContent($event) { $chemin = jApp::config()->urlengine['basePath'] . 'hfnu/admin/'; $event->add(new masterAdminMenuItem('hfnusearch', jLocale::get('hfnusearch~search.admin.search.engine'), '', 50)); if (jAcl2::check('hfnu.admin.search')) { $item = new masterAdminMenuItem('hfnusearch', jLocale::get('hfnusearch~search.admin.search.engine'), jUrl::get('hfnusearch~admin:index'), 100, 'hfnusearch'); $item->icon = $chemin . 'images/search_engine.png'; $event->add($item); } }
/** * Add data in a certain mime type format to the application. * @param mixed $data data for adding to the application, the datatype depends on the mime type * @param string $type specifies the mime type version of the passed data * @param string $version specifies the mime type version of the passed data * @return integer id of the added data */ function addData($data, $type, $version = '') { // 1: mapping the mime type to application data $dataIntern = $this->_importData($data, $type, $version); if ($dataIntern == false) { return false; } // 2: add data to application return $this->bo->add($dataIntern); }
/** * 增加新的推荐位 * * @param string $data * @access public * @return boolean true|false */ public function addPosition(\App\Services\Admin\Position\Param\PositionSave $data) { if (!$this->positionValidate->add($data)) { return $this->setErrorMsg($this->positionValidate->getErrorMessage()); } $data = $data->toArray(); $data['is_delete'] = PositionModel::IS_DELETE_NO; if ($this->positionModel->addPosition($data) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * Validate the extra register fields. * * @param string $username Current username. * @param string $email Current email. * @param object $validation_errors WP_Error object. * * @return void */ function wooc_validate_extra_register_fields($username, $email, $validation_errors) { if (isset($_POST['billing_first_name']) && empty($_POST['billing_first_name'])) { $validation_errors->add('billing_first_name_error', __('<strong>Error</strong>: First name is required!', 'woocommerce')); } if (isset($_POST['billing_last_name']) && empty($_POST['billing_last_name'])) { $validation_errors->add('billing_last_name_error', __('<strong>Error</strong>: Last name is required!.', 'woocommerce')); } if (isset($_POST['billing_phone']) && empty($_POST['billing_phone'])) { $validation_errors->add('billing_phone_error', __('<strong>Error</strong>: Phone is required!.', 'woocommerce')); } }
/** * 增加新的分类 * * @param object $data * @access public * @return boolean true|false */ public function addCategory(\App\Services\Admin\Category\Param\CategorySave $data) { if (!$this->categoryValidate->add($data)) { return $this->setErrorMsg($this->categoryValidate->getErrorMessage()); } $data = $data->toArray(); $data['is_delete'] = CategoryModel::IS_DELETE_NO; $data['time'] = time(); if ($this->categoryModel->addCategory($data) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * 增加新的用户组 * * @param object $data * @return boolean true|false * @access public */ public function addGroup(GroupSave $data) { if (!$this->groupValidate->add($data)) { return $this->setErrorMsg($this->groupValidate->getErrorMessage()); } if (!$this->acl->checkGroupLevelPermission($data->level, Acl::GROUP_LEVEL_TYPE_LEVEL)) { return $this->setErrorMsg(Lang::get('common.account_level_deny')); } if ($this->groupModel->addGroup($data->toArray()) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * 以查询的方式添加类型 * * @return int 类型ID * @author Medz Seven <*****@*****.**> **/ protected function selectAddType($type) { /* # 检查是否是合法的类型 */ if (!isset($this->types[$type]) or !$this->types[$type]) { $this->_error = '保护字段不合法'; return false; /* # 查询类型ID or 添加 */ } elseif (!($typeID = $this->typeModel->where('`type_name` LIKE \'' . $this->types[$type] . '\'')->field(`type_id`)->getField('type_id')) and !($typeID = $this->typeModel->add(array('type_name' => $this->types[$type])))) { $this->_error = '无法增加反馈类型'; return false; } return $typeID; }
/** * Function used to build form element for new contact or select contact widget * * @param object $form form object * @param int $blocNo by default it is one, except for address block where it is * build for each block * @param array $extrProfiles extra profiles that should be included besides reserved * * @access public * * @return void */ static function buildQuickForm(&$form, $blockNo = 1, $extraProfiles = NULL, $required = FALSE, $prefix = '') { // call to build contact autocomplete $attributes = array('width' => '200px'); $form->add('text', "{$prefix}contact[{$blockNo}]", ts('Select Contact'), $attributes, $required); $form->addElement('hidden', "{$prefix}contact_select_id[{$blockNo}]"); if (CRM_Core_Permission::check('edit all contacts') || CRM_Core_Permission::check('add contacts')) { // build select for new contact $contactProfiles = CRM_Core_BAO_UFGroup::getReservedProfiles('Contact', $extraProfiles); $form->add('select', "{$prefix}profiles[{$blockNo}]", ts('Create New Contact'), array('' => ts('- create new contact -')) + $contactProfiles, FALSE, array('onChange' => "if (this.value) { newContact{$prefix}{$blockNo}( this.value, {$blockNo}, '{$prefix}' );}")); } $form->assign('blockNo', $blockNo); $form->assign('prefix', $prefix); }
/** * 增加新的用户组 * * @param object $data * @access public * @return boolean true|false */ public function addGroup(\App\Services\Admin\Group\Param\GroupSave $data) { if (!$this->groupValidate->add($data)) { return $this->setErrorMsg($this->groupValidate->getErrorMessage()); } //检查当前用户的权限是否能增加这个用户组 if (!app('admin.acl')->checkGroupLevelPermission($data->level, Acl::GROUP_LEVEL_TYPE_LEVEL)) { return $this->setErrorMsg(Lang::get('common.account_level_deny')); } if (app('model.admin.group')->addGroup($data->toArray()) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * 增加新的权限菜单 * * @param object $data * @return boolean true|false * @access public */ public function addShopCategory(CategorySave $data) { if (!$this->productCategoryValidate->add($data)) { return $this->setErrorMsg($this->productCategoryValidate->getErrorMessage()); } if ($this->productCategoryModel->checkIfIsExists($data->category_name)) { return $this->setErrorMsg(Lang::get('shopcategory.name_exists')); } $data = $data->toArray(); if ($this->productCategoryModel->addShopCategory($data) === false) { return $this->setErrorMsg(Lang::get('common.action_error')); } return true; }
/** * 增加新的权限菜单 * * @param object $data * @return boolean true|false * @access public */ public function addAcl(AclSave $data) { if (!$this->aclValidate->add($data)) { return $this->setErrorMsg($this->aclValidate->getErrorMessage()); } if ($this->permissionModel->checkIfIsExists($data->module, $data->class, $data->action)) { return $this->setErrorMsg(Lang::get('acl.acl_exists')); } $data = $data->toArray(); if ($this->permissionModel->addPermission($data) === false) { return $this->setErrorMsg(Lang::get('common.action_error')); } return true; }
/** * Method to add a child to the object. * * @access public * @param object * @return uniqueID|false the unique id new row, or false if it exists already. */ public function add($objChild) { // Set this objects properties $this->setProperties($objChild); // Add a condition to this rule. $this->_objChild->add($objChild, $this); }
public function save_attrib($attrib, $action = '') { $receipt = array(); $attrib['appname'] = $this->type_app[$this->type]; $attrib['location'] = ".{$this->type}.{$attrib['entity_id']}.{$attrib['cat_id']}"; $attrib_table = $GLOBALS['phpgw']->locations->get_attrib_table($attrib['appname'], $attrib['location']); if ($action == 'edit' && $attrib['id']) { if ($this->custom->edit($attrib)) { $receipt = $this->custom->receipt; $receipt['message'][] = array('msg' => lang('Field has been updated')); return $receipt; } $receipt['error'][] = array('msg' => lang('Unable to update field')); return $receipt; } else { $id = $this->custom->add($attrib, $attrib_table); if ($id <= 0) { $receipt['error'][] = array('msg' => lang('Unable to add field')); return $receipt; } else { if ($id == -1) { $receipt['id'] = 0; $receipt['error'][] = array('msg' => lang('field already exists, please choose another name')); $receipt['error'][] = array('msg' => lang('Attribute has NOT been saved')); return $receipt; } } $receipt['id'] = $id; $receipt['message'][] = array('msg' => lang('Custom field has been created')); return $receipt; } }
/** * Добавляем активную иконку в меню * * @param object $menu */ public function hookUserMenu($menu) { if (!user()->id) { return; } $menu->add(array('label' => icon('user'), 'tooltip' => t('Профиль'), 'link' => user()->getLink(), 'place' => 'left', 'title' => FALSE, 'order' => 3)); }
/** * 增加新的权限菜单 * * @param string $data * @access public * @return boolean true|false */ public function addAcl(\App\Services\Admin\Acl\Param\AclSave $data) { if (!$this->aclValidate->add($data)) { return $this->setErrorMsg($this->aclValidate->getErrorMessage()); } if ($this->permissionModel->checkIfIsExists($data->module, $data->class, $data->action)) { return $this->setErrorMsg(Lang::get('acl.acl_exists')); } $info = $this->permissionModel->getOnePermissionById(intval($data->pid)); $data = $data->toArray(); $data['level'] = $info['level'] + 1; if ($this->permissionModel->addPermission($data) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * Fire Error * @param object $code [optional] * @param object $args [optional] * @return */ function fire_error($code = '', $args = '') { $defaults = array('code' => 'generic_error', 'message' => _('An unknown error occured.'), 'values' => null, 'debug' => 0); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); $this->error->add($code, sprintf(_($message), $values), $debug); }
public function admin_load_scripts() { // very defaults scripts (in wordpress defaults) wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_script('jquery-ui-slider'); wp_enqueue_script('jquery-ui-autocomplete'); wp_enqueue_script('thickbox'); // date & time picker if (!wp_script_is('jquery-timepicker')) { wp_enqueue_script('jquery-timepicker', $this->cfg['paths']['freamwork_dir_url'] . 'js/jquery.timepicker.v1.1.1.min.js', array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-slider')); } // star rating - rateit if (!wp_style_is('jquery-rateit-css')) { wp_enqueue_style('jquery-rateit-css', $this->cfg['paths']['freamwork_dir_url'] . 'js/rateit/rateit.css'); } if (!wp_script_is('jquery-rateit-js')) { wp_enqueue_script('jquery-rateit-js', $this->cfg['paths']['freamwork_dir_url'] . 'js/rateit/jquery.rateit.min.js', array('jquery')); } if (count($this->cfg['freamwork-js-files']) > 0) { foreach ($this->cfg['freamwork-js-files'] as $key => $value) { if (is_file($this->cfg['paths']['freamwork_dir_path'] . $value)) { wp_enqueue_script($this->alias . '-' . $key, $this->cfg['paths']['freamwork_dir_url'] . $value); } else { $this->errors->add('warning', __('Invalid JS path to file: <strong>' . $this->cfg['paths']['freamwork_dir_path'] . $value . '</strong> . Call in:' . __FILE__ . ":" . __LINE__, $this->localizationName)); } } } }
public function save_attrib($attrib, $action = '') { $attrib['appname'] = 'property'; $attrib['location'] = '.location.' . $attrib['type_id']; $primary_table = 'fm_location' . $attrib['type_id']; $history_table = $primary_table . '_history'; if ($action == 'edit' && $attrib['id']) { if ($this->custom->edit($attrib, $history_table, true)) { $this->custom->edit($attrib, $primary_table); return array('msg' => array('msg' => lang('Field has been updated'))); } return array('error' => lang('Unable to update field')); } else { $id = $this->custom->add($attrib, $primary_table); $this->custom->add($attrib, $history_table, true); if ($id <= 0) { return array('error' => lang('Unable to add field')); } else { if ($id == -1) { return array('id' => 0, 'error' => array(array('msg' => lang('field already exists, please choose another name')), array('msg' => lang('Attribute has NOT been saved')))); } } return array('id' => $id, 'msg' => array('msg' => lang('Custom field has been created'))); } }
/** * Add debug log message * * @since 1.1 * @param string $message */ public static function add_debug_log($message) { if (!is_object(self::$log)) { self::$log = WC_Compat_iPay88::get_wc_logger(); } self::$log->add('ipay88', $message); }
/** * Bootstrap the application by filling all the needed variables and RUN! * * @param array $args Argument array from CLI * @return void */ public function run(array $args = []) { $container = (require path('configs') . 'dependencies.php'); $this->slim =& new App($container); $this->logger['kernel'] = new Logger(Logger::CHANNEL_KERNEL); $this->logger['slim'] = new Logger(Logger::CHANNEL_SLIM); // ExHan if (static::env() == static::DEVELOPMENT) { $this->slim->add(new ExHanMiddleware()); } else { $this->slim->add(new ServerErrorMiddleware()); } $this->registerEvents(); //require path('configs') . 'events.php'; $this->emitter->emit('app.start'); // Defines the middleware from here. // Just a workaround... $config = new SessionConfig(['name' => Config::get('kernel.session.name', 'session'), 'autorefresh' => Config::get('kernel.session.autorefresh', false), 'lifetime' => Config::get('kernel.session.lifetime', '1 hour')]); $this->session = new Handler($config); $this->cookies = new CookieJar(); $middlewares = (require path('configs') . 'middlewares.php'); foreach ($middlewares as $middleware) { $this->slim->add($middleware); $this->emitter->emit('app.middleware.load', [$middleware]); } require path('configs') . 'routes.php'; $this->slim->run(); $this->emitter->emit('app.finish'); }
/** * 发送数据到客户端 * @return bool */ public function sendToClient($str_to_send) { // tcp if ($this->protocol != 'udp') { $send_len = @fwrite($this->connections[$this->currentDealFd], $str_to_send); if ($send_len === strlen($str_to_send)) { return true; } if ($send_len > 0) { $this->sendBuffers[$this->currentDealFd] = substr($str_to_send, $send_len); } else { $this->sendBuffers[$this->currentDealFd] = $str_to_send; } if (!isset($this->connections[$this->currentDealFd])) { $debug_str = new \Exception('sendToClient fail $this->connections[$this->currentDealFd] is null'); $this->notice((string) $debug_str); return false; } if (feof($this->connections[$this->currentDealFd])) { return false; } $this->event->add($this->connections[$this->currentDealFd], Events\BaseEvent::EV_WRITE, array($this, 'tcpWriteToClient')); return null; } // udp 直接发送,要求数据包不能超过65515 return strlen($str_to_send) == stream_socket_sendto($this->mainSocket, $str_to_send, 0, $this->currentClientAddress); }
/** * 发送数据到客户端 * @return bool */ public function sendToClient($str_to_send) { // tcp if ($this->protocol != 'udp') { $send_len = @stream_socket_sendto($this->connections[$this->currentDealFd], $str_to_send); if ($send_len === strlen($str_to_send)) { return true; } if ($send_len > 0) { $this->sendBuffers[$this->currentDealFd] = substr($str_to_send, $send_len); } else { $this->sendBuffers[$this->currentDealFd] = $str_to_send; } $this->event->add($this->connections[$this->currentDealFd], Events\BaseEvent::EV_WRITE, array($this, 'tcpWriteToClient'), array($this->currentDealFd)); /* // tcp 如果一次没写完(一般是缓冲区满的情况),则阻塞写 if(!$this->blockWrite($this->connections[$this->currentDealFd], $str_to_send, 500)) { $this->notice('sendToClient fail ,Data length = ' . strlen($str_to_send)); $this->statusInfo['send_fail']++; return false; }*/ return null; } // udp 直接发送,要求数据包不能超过65515 return strlen($str_to_send) == stream_socket_sendto($this->mainSocket, $str_to_send, 0, $this->currentClientAddress); }
/** * Cancel current sleep * @return void */ public function wakeup() { if ($this->state === Generic::STATE_WAITING) { $this->ev->del(); $this->ev->add(0); } }