本文整理汇总了PHP中Current类的典型用法代码示例。如果您正苦于以下问题:PHP Current类的具体用法?PHP Current怎么用?PHP Current使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Current类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: createMailSettingFixedPhrase
/**
* メール設定-定型文 データ新規作成
*
* @param int $languageId 言語ID
* @param string $typeKey メール定型文の種類
* @param string $pluginKey プラグインキー
* @return array メール設定データ配列
*/
public function createMailSettingFixedPhrase($languageId = null, $typeKey = self::DEFAULT_TYPE, $pluginKey = null)
{
if ($languageId === null) {
$languageId = Current::read('Language.id');
}
if ($pluginKey === null) {
$pluginKey = Current::read('Plugin.key');
}
//デフォルトデータ取得
$conditions = array('language_id' => $languageId, 'plugin_key' => $pluginKey, 'block_key' => null, 'type_key' => $typeKey);
$mailFixedPhrase = $this->getMailSettingFixedPhrase($conditions);
if ($mailFixedPhrase) {
$mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.id');
} else {
$mailFixedPhrase = $this->create();
$mailFixedPhrase[$this->alias]['type_key'] = $typeKey;
}
//初期データセット
$this->__noSetData('mail_fixed_phrase_subject', $mailFixedPhrase, $typeKey);
$this->__noSetData('mail_fixed_phrase_body', $mailFixedPhrase, $typeKey);
$mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.created');
$mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.created_user');
$mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.modified');
$mailFixedPhrase = Hash::remove($mailFixedPhrase, '{s}.modified_user');
return $mailFixedPhrase;
}
开发者ID:NetCommons3,项目名称:Mails,代码行数:34,代码来源:MailSettingFixedPhrase.php
示例2: getRegistrationForAnswerCsv
/**
* getRegistrationForAnswerCsv
*
* @param int $registrationKey registration key
* @return array registration data
*/
public function getRegistrationForAnswerCsv($registrationKey)
{
// 指定の登録フォームデータを取得
// CSVの取得は公開してちゃんとした登録を得ている登録フォームに限定である
$registration = $this->Registration->find('first', array('conditions' => array('Registration.block_id' => Current::read('Block.id'), 'Registration.key' => $registrationKey, 'Registration.is_active' => true, 'Registration.language_id' => Current::read('Language.id')), 'recursive' => -1));
return $registration;
}
开发者ID:NetCommons3,项目名称:Registrations,代码行数:13,代码来源:RegistrationAnswerSummaryCsv.php
示例3: edit
/**
* edit
*
* @return void
*/
public function edit()
{
//会員権限リストを取得する
$userRoles = $this->UserRole->find('list', array('recursive' => -1, 'fields' => array('key', 'name'), 'conditions' => array('language_id' => Current::read('Language.id')), 'order' => array('id' => 'asc')));
$this->set('userRoles', $userRoles);
//リクエストセット
if ($this->request->is('post')) {
$data = $this->request->data['SiteSetting'];
$value = $data['Security.deny_ip_move']['0']['value'];
if (is_array($value)) {
$data['Security.deny_ip_move']['0']['value'] = implode('|', $value);
}
//登録処理
$this->request->data['SiteSetting'] = $data;
$this->SiteSetting->userRoles = $userRoles;
$this->SiteManager->saveData();
} else {
$this->request->data['SiteSetting'] = $this->SiteSetting->getSiteSettingForEdit(array('SiteSetting.key' => array('Upload.allow_extension', 'Security.deny_ip_move', 'Security.enable_bad_ips', 'Security.bad_ips', 'Security.enable_allow_system_plugin_ips', 'Security.allow_system_plugin_ips')));
$ips = $this->request->data['SiteSetting']['Security.allow_system_plugin_ips']['0']['value'];
if (!$this->SiteSetting->hasCurrentIp($ips)) {
$ips = Hash::get($_SERVER, 'REMOTE_ADDR');
$this->request->data['SiteSetting']['Security.allow_system_plugin_ips']['0']['value'] = $ips;
}
}
}
开发者ID:NetCommons3,项目名称:SystemManager,代码行数:30,代码来源:SecuritySettingsController.php
示例4: dropDownToggle
/**
* Output categories drop down toggle
*
* #### Options
*
* - `empty`: String is empty label.
* - `header`: String is header label.
* - `divider`: True is divider.
* - `displayMenu`: True is display menu. False is <li> tag only.
* - `displayEmpty`: True is empty display. False is not display.
*
* @param array $options Array of options and HTML arguments.
* @return string HTML tags
*/
public function dropDownToggle($options = array())
{
//カレントCategoryId
if (isset($this->_View->params['named']['category_id'])) {
$currentCategoryId = $this->_View->params['named']['category_id'];
} else {
$currentCategoryId = '0';
}
//URLのセット
if (!isset($options['url'])) {
$options['url'] = array('plugin' => $this->_View->params['plugin'], 'controller' => $this->_View->params['controller'], 'action' => $this->_View->params['action'], Current::read('Frame.id'));
}
//オプションのセット
if (isset($options['empty']) && $options['empty']) {
if (is_string($options['empty'])) {
$name = $options['empty'];
//呼び出しもとでhtmlspecialcharsする
} else {
$name = __d('categories', 'Select Category');
}
$options['categories'] = array('0' => array('id' => null, 'name' => $name));
} else {
$options['categories'] = array();
}
$options['categories'] = Hash::merge($options['categories'], Hash::combine($this->_View->viewVars['categories'], '{n}.Category.id', '{n}.Category'));
if (isset($options['header']) && $options['header']) {
if (!is_string($options['header'])) {
$options['header'] = __d('categories', 'Category');
}
}
return $this->_View->element('Categories.dropdown_toggle_category', array('currentCategoryId' => $currentCategoryId, 'options' => $options));
}
开发者ID:Onasusweb,项目名称:Categories,代码行数:46,代码来源:CategoryHelper.php
示例5: __construct
public function __construct()
{
Cowl::timer('cowl init');
@session_start();
// I know that the @-notation is frowned upon, but adding it to session_start saves us unnecessary warnings
Cache::setDir(COWL_CACHE_DIR);
Current::initialize(COWL_DIR);
if (COWL_CLI) {
$this->parseCLIPath();
} else {
$this->parseRequestPath();
}
Cowl::timer('cowl set defaults');
// Get and set all directories for various things.
list($commands_dir, $model_dir, $validators_dir, $library_dir, $view_dir, $helpers_dir, $helpers_app_dir, $drivers_dir, $app_dir, $view_layout_dir, $validator_error_messages, $lang) = Current::$config->gets('paths.commands', 'paths.model', 'paths.validators', 'paths.library', 'paths.view', 'paths.helpers', 'paths.helpers_app', 'paths.drivers', 'paths.app', 'paths.layouts', 'paths.validator_messages', 'lang');
Controller::setDir($commands_dir);
DataMapper::setMappersDir($model_dir);
DataMapper::setObjectsDir($model_dir);
Validator::setPath($validators_dir);
Validator::loadStrings($validator_error_messages, $lang);
Templater::setBaseDir($view_dir);
Templater::setLayoutDir($view_layout_dir);
Library::setPath($library_dir);
Helpers::setPath($helpers_dir);
Helpers::setAppPath($helpers_app_dir);
Database::setPath($drivers_dir);
StaticServer::setDir($app_dir);
Cowl::timerEnd('cowl set defaults');
Cowl::timer('cowl plugins load');
Current::$plugins = new Plugins();
Cowl::timerEnd('cowl plugins load');
// Load default helper
Helpers::load('standard', 'form');
Cowl::timerEnd('cowl init');
}
开发者ID:erkie,项目名称:cowl,代码行数:35,代码来源:frontcontroller.php
示例6: canUserEdit
/**
* ユーザの編集出来るかどうか
*
* @param Model $model ビヘイビア呼び出し元モデル
* @param array $user ユーザデータ
* @return bool
*/
public function canUserEdit(Model $model, $user)
{
if (!$user || Current::read('User.role_key') !== UserRole::USER_ROLE_KEY_SYSTEM_ADMINISTRATOR && $user['User']['role_key'] === UserRole::USER_ROLE_KEY_SYSTEM_ADMINISTRATOR) {
return false;
}
return true;
}
开发者ID:akagane99,项目名称:Users,代码行数:14,代码来源:UserPermissionBehavior.php
示例7: beforeRender
/**
* beforeRender
*
* @param Controller $controller Controller
* @return void
* @throws NotFoundException
*/
public function beforeRender(Controller $controller)
{
//RequestActionの場合、スキップする
if (!empty($controller->request->params['requested']) || $controller->request->is('ajax')) {
return;
}
//Pluginデータ取得
$controller->Plugin = ClassRegistry::init('PluginManager.Plugin', true);
$controller->PluginsRole = ClassRegistry::init('PluginManager.PluginsRole', true);
$controlPanel = $controller->Plugin->create(array('key' => 'control_panel', 'name' => __d('control_panel', 'Control Panel Top'), 'default_action' => 'control_panel/index'));
$this->plugins = $controller->PluginsRole->getPlugins(array(Plugin::PLUGIN_TYPE_FOR_SITE_MANAGER, Plugin::PLUGIN_TYPE_FOR_SYSTEM_MANGER), Current::read('User.role_key'), 'INNER');
array_unshift($this->plugins, $controlPanel);
//Layoutのセット
$controller->layout = 'ControlPanel.default';
//cancelUrlをセット
$controller->set('cancelUrl', '/');
$controller->set('isControlPanel', true);
$controller->set('hasControlPanel', true);
//ページHelperにセット
$controller->set('pluginsMenu', $this->plugins);
if (isset($this->settings['plugin'])) {
$plugin = $this->settings['plugin'];
} else {
$plugin = $controller->params['plugin'];
}
$plugin = Hash::extract($this->plugins, '{n}.Plugin[key=' . $plugin . ']');
if (isset($plugin[0]['name'])) {
if (!isset($controller->viewVars['title'])) {
$controller->set('title', $plugin[0]['name']);
}
$controller->set('pageTitle', $plugin[0]['name']);
}
}
开发者ID:s-nakajima,项目名称:ControlPanel,代码行数:40,代码来源:ControlPanelLayoutComponent.php
示例8: edit
/**
* edit
*
* @param string $roleKey user_roles.key
* @return void
*/
public function edit($roleKey = null)
{
//既存データ取得
$userRole = $this->UserRole->find('first', array('recursive' => -1, 'conditions' => array('key' => $roleKey, 'language_id' => Current::read('Language.id'))));
if (!$userRole) {
return $this->throwBadRequest();
}
if ($this->request->is('put')) {
//不要パラメータ除去
unset($this->request->data['save']);
//登録処理
if ($this->UserRole->saveUserRolePlugins($this->request->data)) {
//正常の場合
$this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array('class' => 'success'));
return $this->redirect('/user_roles/user_roles/index');
} else {
$this->NetCommons->handleValidationError($this->UserRoleSetting->validationErrors);
$this->redirect('/user_roles/user_roles_plugins/edit/' . h($roleKey));
}
} else {
$this->request->data = $this->UserRoleSetting->getUserRoleSetting(Plugin::PLUGIN_TYPE_FOR_SITE_MANAGER, $roleKey);
$this->request->data = Hash::merge($userRole, $this->request->data);
$this->set('roleKey', $roleKey);
$this->set('subtitle', $this->request->data['UserRole']['name']);
}
}
开发者ID:NetCommons3,项目名称:UserRoles,代码行数:32,代码来源:UserRolesPluginsController.php
示例9: wysiwygScript
/**
* wysiwyg用のスクリプト呼び出し対応
*
* @return String wysiwyg js
*/
public function wysiwygScript()
{
// file / image が送信するフィールド(フォーム改ざん防止項目)
$fields = ['Room' => ['id' => Current::read('Room.id')], 'Block' => ['key' => Current::read('Block.key'), 'room_id' => Current::read('Room.id')], 'Wysiwyg' => ['file' => ['error' => [], 'name' => [], 'size' => [], 'tmp_name' => [], 'type' => []]]];
// NetCommonsApp.constant で定義する変数の定義
$constants = ['NC3_URL' => h(substr(Router::url('/'), 0, -1)), 'title_icon_paths' => $this->__getTitleIconFiles(), 'lang' => Current::read('Language.code'), 'lang_js' => $this->NetCommonsHtml->url('/wysiwyg/js/langs/' . Current::read('Language.code') . '.js'), 'content_css' => [$this->NetCommonsHtml->url('/net_commons/css/style.css'), $this->NetCommonsHtml->url('/components/bootstrap/dist/css/bootstrap.css'), $this->NetCommonsHtml->url('/wysiwyg/css/style.css')], 'blockKey' => Current::read('Block.key'), 'roomId' => Current::read('Room.id'), 'book_icon' => $this->NetCommonsHtml->url('/wysiwyg/img/title_icons/book.svg'), 'fileup_icon' => $this->NetCommonsHtml->url('/wysiwyg/img/title_icons/fileup.svg'), 'tex_icon' => $this->NetCommonsHtml->url('/wysiwyg/img/title_icons/tex.svg'), 'mathjax_js' => $this->NetCommonsHtml->url('/components/MathJax/MathJax.js?config=TeX-MML-AM_CHTML'), 'file_upload_path' => $this->NetCommonsHtml->url('/wysiwyg/file/upload'), 'image_upload_path' => $this->NetCommonsHtml->url('/wysiwyg/image/upload'), 'csrfTokenPath' => $this->NetCommonsHtml->url('/net_commons/net_commons/csrfToken.json'), 'fileSecure' => $this->__secure('/wysiwyg/file/upload', $fields), 'imageSecure' => $this->__secure('/wysiwyg/image/upload', $fields), 'is_mobile' => Configure::read('isMobile')];
// 許可するタグの設定
if (Current::permission('html_not_limited')) {
$constants['extended_valid_elements'] = 'script[src|title|type]';
$constants['cleanup'] = false;
}
// constants 設定を JavaScriptで利用するための設定に変換する
$this->NetCommonsHtml->scriptStart(array('inline' => false));
echo "NetCommonsApp.service('nc3Configs', function() {";
foreach ($constants as $key => $value) {
if (is_array($value)) {
echo 'this.' . $key . ' = ' . json_encode($value) . ';';
} else {
echo "this." . $key . " = '" . $value . "';";
}
}
echo "});";
$this->NetCommonsHtml->scriptEnd();
return $this->_View->element('Wysiwyg.wysiwyg_js');
}
开发者ID:NetCommons3,项目名称:Wysiwyg,代码行数:30,代码来源:WysiwygHelper.php
示例10: readToArticle
/**
* Save BbsArticlesUser
*
* @param object $model instance of model
* @param array $bbsArticleKey received bbs_article_key
* @return mixed On success Model::$data if its not empty or true, false on failure
* @throws InternalErrorException
*/
public function readToArticle(Model $model, $bbsArticleKey)
{
$model->loadModels(['BbsArticlesUser' => 'Bbses.BbsArticlesUser']);
//既読チェック
if (!Current::read('User.id')) {
return true;
}
$count = $model->BbsArticlesUser->find('count', array('recursive' => -1, 'conditions' => array('bbs_article_key' => $bbsArticleKey, 'user_id' => Current::read('User.id'))));
if ($count > 0) {
return true;
}
//トランザクションBegin
$model->BbsArticlesUser->begin();
//バリデーション
$data = $model->BbsArticlesUser->create(array('bbs_article_key' => $bbsArticleKey, 'user_id' => Current::read('User.id')));
$model->BbsArticlesUser->set($data);
if (!$model->BbsArticlesUser->validates()) {
$model->BbsArticlesUser->rollback();
return false;
}
try {
if (!$model->BbsArticlesUser->save(null, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
//トランザクションCommit
$model->BbsArticlesUser->commit();
} catch (Exception $ex) {
//トランザクションRollback
$model->BbsArticlesUser->rollback($ex);
}
return true;
}
开发者ID:Onasusweb,项目名称:Bbses,代码行数:40,代码来源:BbsArticlesUserBehavior.php
示例11: sendMail
/**
* 新規登録のメール処理
*
* @param int $confirmation 完了確認ステータス
* @param array $user ユーザ情報
* @return bool
*/
public function sendMail($confirmation, $user)
{
if ($confirmation === AutoUserRegist::CONFIRMATION_USER_OWN) {
$data['subject'] = SiteSettingUtil::read('AutoRegist.approval_mail_subject');
$data['body'] = SiteSettingUtil::read('AutoRegist.approval_mail_body');
$data['email'] = array($user['User']['email']);
$data['url'] = Router::url('/auth/auto_user_regist/approval', true) . $user['User']['activate_parameter'];
} elseif ($confirmation === AutoUserRegist::CONFIRMATION_ADMIN_APPROVAL) {
$data['subject'] = SiteSettingUtil::read('AutoRegist.acceptance_mail_subject');
$data['body'] = SiteSettingUtil::read('AutoRegist.acceptance_mail_body');
$data['email'] = $this->__getMailAddressForAdmin();
$data['url'] = Router::url('/auth/auto_user_regist/acceptance', true) . $user['User']['activate_parameter'];
} else {
return true;
}
foreach ($data['email'] as $email) {
$this->mail->mailAssignTag->setFixedPhraseSubject($data['subject']);
$this->mail->mailAssignTag->setFixedPhraseBody($data['body']);
$this->mail->mailAssignTag->assignTags(array('X-URL' => $data['url']));
$this->mail->mailAssignTag->initPlugin(Current::read('Language.id'));
$this->mail->initPlugin(Current::read('Language.id'));
$this->mail->to($email);
$this->mail->setFrom(Current::read('Language.id'));
$this->mail->sendMailDirect();
}
return true;
}
开发者ID:s-nakajima,项目名称:Auth,代码行数:34,代码来源:AutoUserRegistMail.php
示例12: beforeValidate
/**
* beforeValidate is called before a model is validated, you can use this callback to
* add behavior validation rules into a models validate array. Returning false
* will allow you to make the validation fail.
*
* @param Model $model Model using this behavior
* @param array $options Options passed from Model::save().
* @return mixed False or null will abort the operation. Any other result will continue.
* @see Model::save()
*/
public function beforeValidate(Model $model, $options = array())
{
//ページデータをセット
$referencePageId = $model->getReferencePageId($model->data);
$fields = array('room_id', 'permalink');
$targetPage = $model->findById($referencePageId, $fields);
if (empty($targetPage)) {
return false;
}
$model->data['Page']['room_id'] = Current::read('Room.id');
$slug = $model->data['Page']['slug'];
if (!isset($slug)) {
$slug = '';
}
$model->data['Page']['slug'] = $slug;
$permalink = '';
if (strlen($targetPage['Page']['permalink']) !== 0) {
$permalink = $targetPage['Page']['permalink'] . '/';
}
$permalink .= $slug;
$model->data['Page']['permalink'] = $permalink;
$model->data['Page']['is_published'] = true;
$model->data['Page']['is_container_fluid'] = false;
return parent::beforeValidate($model, $options);
}
开发者ID:Onasusweb,项目名称:Pages,代码行数:35,代码来源:PageBehavior.php
示例13: beforeRender
/**
* beforeRender
*
* @param Controller $controller Controller
* @return void
* @throws NotFoundException
*/
public function beforeRender(Controller $controller)
{
//RequestActionの場合、スキップする
if (!empty($controller->request->params['requested'])) {
return;
}
$this->controller = $controller;
$this->__prepare();
//pathからページデータ取得
if (isset($this->controller->viewVars['page'])) {
$page = $this->controller->viewVars['page'];
} else {
$this->Page = ClassRegistry::init('Pages.Page');
$page = $this->Page->getPageWithFrame(Current::read('Page.permalink'));
if (empty($page)) {
throw new NotFoundException();
}
}
if (Current::hasSettingMode() && Current::isSettingMode() && Current::permission('page_editable')) {
$this->controller->request->data['ContainersPage'] = Hash::combine($page, 'Container.{n}.type', 'Container.{n}.ContainersPage');
}
////cancelUrlをセット
//if (! isset($this->controller->viewVars['cancelUrl'])) {
// $this->controller->set('cancelUrl', $page['Page']['permalink']);
//}
//Pluginデータ取得
$pluginsRoom = ClassRegistry::init('PluginManager.PluginsRoom');
$plugins = $pluginsRoom->getPlugins($page['Page']['room_id'], Current::read('Language.id'));
//ページHelperにセット
$results = array('containers' => Hash::combine($page['Container'], '{n}.type', '{n}'), 'boxes' => Hash::combine($page['Box'], '{n}.id', '{n}', '{n}.container_id'), 'plugins' => $plugins);
$this->controller->helpers['Pages.PageLayout'] = $results;
}
开发者ID:Onasusweb,项目名称:Pages,代码行数:39,代码来源:PageLayoutComponent.php
示例14: __construct
public function __construct()
{
$date = date("Ymd", $_SERVER['REQUEST_TIME']);
$this->log_file = COWL_TOP . sprintf(Current::$config->get("plugins.logging.log_file"), $date);
$this->error_file = COWL_TOP . sprintf(Current::$config->get("plugins.logging.error_file"), $date);
// Set global accessor as Current::$log
Current::$log = $this;
}
开发者ID:erkie,项目名称:cowl,代码行数:8,代码来源:plugin.logging.php
示例15: setUserRoleAdminOnBasic
/**
* システム管理者以外は、選択肢からシステム管理者を除外
*
* @return void
*/
public function setUserRoleAdminOnBasic()
{
$controller = $this->controller;
//システム管理者以外は、選択肢からシステム管理者を除外
if (UserRole::USER_ROLE_KEY_SYSTEM_ADMINISTRATOR !== Current::read('User.role_key')) {
$controller->viewVars['userAttributes'] = Hash::remove($controller->viewVars['userAttributes'], '{n}.{n}.{n}.UserAttributeChoice.{n}[key=' . UserRole::USER_ROLE_KEY_SYSTEM_ADMINISTRATOR . ']');
}
}
开发者ID:NetCommons3,项目名称:UserManager,代码行数:13,代码来源:UserManagerComponent.php
示例16: getSetting
/**
* getSetting
*
* @return array RegistrationBlockSetting data
*/
public function getSetting()
{
$blockSetting = $this->Block->find('all', array('recursive' => -1, 'conditions' => array('Block.id' => Current::read('Block.id'))));
if (!$blockSetting) {
return $blockSetting;
}
return Hash::merge($blockSetting[0], $this->getBlockSetting());
}
开发者ID:NetCommons3,项目名称:Registrations,代码行数:13,代码来源:RegistrationSetting.php
示例17: __prepare
/**
* 前準備
*
* @return void
*/
private function __prepare()
{
//権限リスト取得
$userRoles = $this->UserRole->find('list', array('recursive' => 0, 'fields' => array('UserRole.key', 'UserRole.name'), 'conditions' => array('UserRole.type' => UserRole::ROLE_TYPE_USER, 'UserRole.language_id' => Current::read('Language.id'), 'UserRoleSetting.is_site_plugins' => false), 'order' => array('UserRole.id' => 'asc')));
$this->set('userRoles', $userRoles);
//会員項目リスト取得
$userAttributes = $this->UserAttribute->find('all', array('recursive' => 0, 'fields' => array('UserAttribute.name', 'UserAttributeSetting.id', 'UserAttributeSetting.required', 'UserAttributeSetting.auto_regist_display', 'UserAttributeSetting.auto_regist_weight'), 'conditions' => array('UserAttribute.language_id' => Current::read('Language.id'), 'UserAttributeSetting.data_type_key NOT' => array('img', 'label'), 'OR' => array('UserAttributeSetting.user_attribute_key' => 'username', 'UserAttributeSetting.only_administrator_editable' => false)), 'order' => array('UserAttributeSetting.auto_regist_weight' => 'asc', 'UserAttributeSetting.row' => 'asc', 'UserAttributeSetting.col' => 'asc', 'UserAttributeSetting.weight' => 'asc')));
$this->set('userAttributes', $userAttributes);
}
开发者ID:NetCommons3,项目名称:SiteManager,代码行数:14,代码来源:MembershipController.php
示例18: getAccessCounterFrameSetting
/**
* Get access counter setting data
*
* @param bool $created If True, the results of the Model::find() to create it if it was null
* @return array
*/
public function getAccessCounterFrameSetting($created)
{
$conditions = array('frame_key' => Current::read('Frame.key'));
$counterFrameSetting = $this->find('first', array('recursive' => -1, 'conditions' => $conditions));
if ($created && !$counterFrameSetting) {
$counterFrameSetting = $this->create(array('id' => null, 'display_type' => self::DISPLAY_TYPE_VALUE_0));
}
return $counterFrameSetting;
}
开发者ID:Onasusweb,项目名称:AccessCounters,代码行数:15,代码来源:AccessCounterFrameSetting.php
示例19: getVideoFrameSetting
/**
* VideoFrameSettingデータ取得
*
* @param bool $created If True, the results of the Model::find() to create it if it was null
* @return array
*/
public function getVideoFrameSetting($created)
{
$conditions = array('frame_key' => Current::read('Frame.key'));
$videoFrameSetting = $this->find('first', array('recursive' => -1, 'conditions' => $conditions));
if ($created && !$videoFrameSetting) {
$videoFrameSetting = $this->create(array('frame_key' => Current::read('Frame.key')));
}
return $videoFrameSetting;
}
开发者ID:s-nakajima,项目名称:videos,代码行数:15,代码来源:VideoFrameSetting.php
示例20: unzip
/**
* キャビネットファイルのUnzip
*
* @param Model $model CabinetFile
* @param array $cabinetFile CabinetFileデータ
* @return bool
* @throws InternalErrorException
*/
public function unzip(Model $model, $cabinetFile)
{
$model->begin();
try {
// テンポラリフォルダにunzip
$zipPath = WWW_ROOT . $cabinetFile['UploadFile']['file']['path'] . $cabinetFile['UploadFile']['file']['id'] . DS . $cabinetFile['UploadFile']['file']['real_file_name'];
//debug($zipPath);
App::uses('UnZip', 'Files.Utility');
$unzip = new UnZip($zipPath);
$tmpFolder = $unzip->extract();
if ($tmpFolder === false) {
throw new InternalErrorException('UnZip Failed.');
}
$parentCabinetFolder = $model->find('first', ['conditions' => ['CabinetFileTree.id' => $cabinetFile['CabinetFileTree']['parent_id']]]);
// unzipされたファイル拡張子のバリデーション
// unzipされたファイルのファイルサイズバリデーション
$files = $tmpFolder->findRecursive();
$unzipTotalSize = 0;
foreach ($files as $file) {
//
$unzipTotalSize += filesize($file);
// ここでは拡張子だけチェックする
$extension = pathinfo($file, PATHINFO_EXTENSION);
if (!$model->isAllowUploadFileExtension($extension)) {
// NG
$model->validationErrors = [__d('cabinets', 'Unzip failed. Contains does not allow file format.')];
return false;
}
}
// ルームファイルサイズ制限
$maxRoomDiskSize = Current::read('Space.room_disk_size');
if ($maxRoomDiskSize !== null) {
// nullだったらディスクサイズ制限なし。null以外ならディスクサイズ制限あり
// 解凍後の合計
// 現在のルームファイルサイズ
$roomId = Current::read('Room.id');
$roomFileSize = $model->getTotalSizeByRoomId($roomId);
if ($roomFileSize + $unzipTotalSize > $maxRoomDiskSize) {
$model->validationErrors[] = __d('cabinets', 'Failed to expand. The total size exceeds the limit.<br />' . 'The total size limit is %s (%s left).', CakeNumber::toReadableSize($roomFileSize + $unzipTotalSize), CakeNumber::toReadableSize($maxRoomDiskSize));
return false;
}
}
// 再帰ループで登録処理
list($folders, $files) = $tmpFolder->read(true, false, true);
foreach ($files as $file) {
$this->_addFileFromPath($model, $parentCabinetFolder, $file);
}
foreach ($folders as $folder) {
$this->_addFolderFromPath($model, $parentCabinetFolder, $folder);
}
} catch (Exception $e) {
return $model->rollback($e);
}
$model->commit();
return true;
}
开发者ID:NetCommons3,项目名称:Cabinets,代码行数:64,代码来源:CabinetUnzipBehavior.php
注:本文中的Current类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论