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


PHP iaUtil::loadUTF8Functions方法代码示例

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


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

示例1: _preSaveEntry

 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     $entry = array('name' => iaUtil::checkPostParam('name'), 'item' => iaUtil::checkPostParam('item'), 'collapsible' => iaUtil::checkPostParam('collapsible'), 'collapsed' => iaUtil::checkPostParam('collapsed'), 'tabview' => iaUtil::checkPostParam('tabview'), 'tabcontainer' => iaUtil::checkPostParam('tabcontainer'));
     iaUtil::loadUTF8Functions('ascii', 'bad', 'validation');
     if (iaCore::ACTION_ADD == $action) {
         if (!utf8_is_ascii($entry['name'])) {
             $this->addMessage('ascii_required');
         } else {
             $entry['name'] = strtolower($entry['name']);
         }
         if (!$this->getMessages() && !preg_match('/^[a-z0-9\\-_]{2,50}$/', $entry['name'])) {
             $this->addMessage('name_is_incorrect');
         }
         if (empty($data['item'])) {
             $this->addMessage('at_least_one_item_should_be_checked');
         }
         $entry['order'] = $this->_iaDb->getMaxOrder(iaField::getTableGroups()) + 1;
     }
     foreach ($this->_iaCore->languages as $code => $language) {
         if ($data['titles'][$code]) {
             if (!utf8_is_valid($data['titles'][$code])) {
                 $data['titles'][$code] = utf8_bad_replace($data['titles'][$code]);
             }
         } else {
             $this->addMessage($language['title'] . ': ' . iaLanguage::get('title_incorrect'), false);
         }
         if ($data['description'][$code]) {
             if (!utf8_is_valid($data['description'][$code])) {
                 $data['description'][$code] = utf8_bad_replace($data['description'][$code]);
             }
         }
     }
     return !$this->getMessages();
 }
开发者ID:TalehFarzaliey,项目名称:subrion,代码行数:34,代码来源:fieldgroups.php

示例2: _preSaveEntry

 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     parent::_preSaveEntry($entry, $data, $action);
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     if (!utf8_is_valid($entry['title'])) {
         $entry['title'] = utf8_bad_replace($entry['title']);
     }
     if (empty($entry['title'])) {
         $this->addMessage('title_is_empty');
     }
     if (!utf8_is_valid($entry['body'])) {
         $entry['body'] = utf8_bad_replace($entry['body']);
     }
     if (empty($entry['body'])) {
         $this->addMessage(iaLanguage::getf('field_is_empty', array('field' => iaLanguage::get('body'))), false);
     }
     if (empty($entry['date_added'])) {
         $entry['date_added'] = date(iaDb::DATETIME_FORMAT);
     }
     $entry['alias'] = $this->getHelper()->titleAlias(empty($entry['alias']) ? $entry['title'] : $entry['alias']);
     if ($this->getMessages()) {
         return false;
     }
     unset($entry['owner'], $entry['tags']);
     if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
         $iaPicture = $this->_iaCore->factory('picture');
         $info = array('image_width' => 1000, 'image_height' => 750, 'thumb_width' => 250, 'thumb_height' => 250, 'resize_mode' => iaPicture::CROP);
         if ($image = $iaPicture->processImage($_FILES['image'], iaUtil::getAccountDir(), iaUtil::generateToken(), $info)) {
             empty($entry['image']) || $iaPicture->delete($entry['image']);
             // already has an assigned image
             $entry['image'] = $image;
         }
     }
     return true;
 }
开发者ID:intelliants,项目名称:subrion,代码行数:35,代码来源:index.php

示例3: _preSaveEntry

 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     $iaAcl = $this->_iaCore->factory('acl');
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     $entry['id'] = $iaAcl->obtainFreeId();
     $entry['assignable'] = $data['visible'];
     $entry['visible'] = $data['visible'];
     if (iaCore::ACTION_ADD == $action) {
         if (empty($data['name'])) {
             $this->addMessage('error_usergroup_incorrect');
         } else {
             $entry['name'] = strtolower(iaSanitize::paranoid($data['name']));
             if (!iaValidate::isAlphaNumericValid($entry['name'])) {
                 $this->addMessage('error_usergroup_incorrect');
             } elseif ($this->_iaDb->exists('`name` = :name', array('name' => $entry['name']))) {
                 $this->addMessage('error_usergroup_exists');
             }
         }
     }
     foreach ($this->_iaCore->languages as $iso => $title) {
         if (empty($data['title'][$iso])) {
             $this->addMessage(iaLanguage::getf('error_lang_title', array('lang' => $this->_iaCore->languages[$iso])), false);
         } elseif (!utf8_is_valid($data['title'][$iso])) {
             $data['title'][$iso] = utf8_bad_replace($data['title'][$iso]);
         }
     }
     if (!$this->getMessages()) {
         foreach ($this->_iaCore->languages as $iso => $title) {
             iaLanguage::addPhrase('usergroup_' . $entry['name'], $data['title'][$iso], $iso);
         }
     }
     return !$this->getMessages();
 }
开发者ID:nicefirework,项目名称:subrion,代码行数:33,代码来源:usergroups.php

示例4: titleAlias

 public function titleAlias($title)
 {
     $result = iaSanitize::tags($title);
     $this->iaCore->factory('util');
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     utf8_is_ascii($result) || ($result = utf8_to_ascii($result));
     $result = preg_replace('#' . self::ALIAS_SUFFIX . '$#i', '', $result);
     $result = iaSanitize::alias($result);
     $result = substr($result, 0, 150);
     // the DB scheme applies this limitation
     $result .= self::ALIAS_SUFFIX;
     return $result;
 }
开发者ID:kreativmind,项目名称:subrion,代码行数:13,代码来源:ia.admin.blog.php

示例5: _preSaveEntry

 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     parent::_preSaveEntry($entry, $data, $action);
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     if (!utf8_is_valid($entry['title'])) {
         $entry['title'] = utf8_bad_replace($entry['title']);
     }
     if (empty($entry['title'])) {
         $this->addMessage('title_is_empty');
     }
     if (!utf8_is_valid($entry['body'])) {
         $entry['body'] = utf8_bad_replace($entry['body']);
     }
     if (empty($entry['body'])) {
         $this->addMessage('body_is_empty');
     }
     if (empty($entry['date_added'])) {
         $entry['date_added'] = date(iaDb::DATETIME_FORMAT);
     }
     $entry['alias'] = $this->getHelper()->titleAlias(empty($entry['alias']) ? $entry['title'] : $entry['alias']);
     if (!empty($data['owner'])) {
         if ($memberId = $this->_iaCore->iaDb->one_bind('id', '`username` = :name OR `fullname` = :name', array('name' => iaSanitize::sql($_POST['owner'])), iaUsers::getTable())) {
             $entry['member_id'] = $memberId;
         } else {
             $this->addMessage('incorrect_owner_specified');
         }
     } else {
         $entry['member_id'] = iaUsers::getIdentity()->id;
     }
     if ($this->getMessages()) {
         return false;
     }
     unset($entry['owner']);
     if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
         $iaPicture = $this->_iaCore->factory('picture');
         $path = iaUtil::getAccountDir();
         $file = $_FILES['image'];
         $token = iaUtil::generateToken();
         $info = array('image_width' => 1000, 'image_height' => 750, 'thumb_width' => 250, 'thumb_height' => 250, 'resize_mode' => iaPicture::CROP);
         if ($image = $iaPicture->processImage($file, $path, $token, $info)) {
             if ($entry['image']) {
                 $iaPicture = $this->_iaCore->factory('picture');
                 $iaPicture->delete($entry['image']);
             }
             $entry['image'] = $image;
         }
     }
     unset($entry['tags']);
     return true;
 }
开发者ID:bohmszi,项目名称:kdbe_cms,代码行数:50,代码来源:index.php

示例6: _preSaveEntry

 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     parent::_preSaveEntry($entry, $data, $action);
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     if (!utf8_is_valid($entry['title'])) {
         $entry['title'] = utf8_bad_replace($entry['title']);
     }
     if (empty($entry['title'])) {
         $this->addMessage('title_is_empty');
     }
     if (!utf8_is_valid($entry['body'])) {
         $entry['body'] = utf8_bad_replace($entry['body']);
     }
     if (empty($entry['body'])) {
         $this->addMessage('body_is_empty');
     }
     if (empty($entry['date_added'])) {
         $entry['date_added'] = date(iaDb::DATETIME_FORMAT);
     }
     $entry['alias'] = $this->getHelper()->titleAlias(empty($entry['alias']) ? $entry['title'] : $entry['alias']);
     if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
         $this->_iaCore->loadClass(iaCore::CORE, 'picture');
         $iaImage = $this->_iaCore->factoryPlugin($this->getPluginName(), iaCore::ADMIN, 'image');
         $imageData = json_decode($entry['image-data'], true);
         $path = iaUtil::getAccountDir();
         $file = $_FILES['image'];
         $token = iaUtil::generateToken();
         $info = array('image_width' => $this->_iaCore->get('portfolio_image_width'), 'image_height' => $this->_iaCore->get('portfolio_image_height'), 'crop_width' => $imageData['width'], 'crop_height' => $imageData['height'], 'thumb_width' => $this->_iaCore->get('portfolio_thumbnail_width'), 'thumb_height' => $this->_iaCore->get('portfolio_thumbnail_height'), 'positionX' => $imageData['x'], 'positionY' => $imageData['y'], 'position' => 'LT', 'resize' => 'after_crop', 'resize_mode' => iaImage::CROP);
         if ($image = $iaImage->processFolioImage($file, $path, $token, $info)) {
             if ($entry['image']) {
                 $iaImage = $this->_iaCore->factory('picture');
                 $iaImage->delete($entry['image']);
             }
             $entry['image'] = $image;
         }
     }
     if (empty($entry['image'])) {
         $this->addMessage('invalid_image_file');
     }
     if ($this->getMessages()) {
         return false;
     }
     unset($entry['image-src']);
     unset($entry['image-data']);
     return true;
 }
开发者ID:NIXAP,项目名称:subrion-plugin-portfolio,代码行数:46,代码来源:index.php

示例7: _postSaveEntry

 protected function _postSaveEntry(array &$entry, array $data, $action)
 {
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     foreach ($this->_iaCore->languages as $code => $language) {
         $title = utf8_is_valid($data['title'][$code]) ? $data['title'][$code] : utf8_bad_replace($data['title'][$code]);
         iaLanguage::addPhrase('usergroup_' . $entry['name'], $title, $code);
     }
     // copy privileges
     $copyFrom = isset($data['copy_from']) ? (int) $data['copy_from'] : 0;
     if ($copyFrom) {
         $this->_iaDb->setTable('acl_privileges');
         $rows = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, "`type_id` = '{$copyFrom}' AND `type` = 'group'");
         foreach ($rows as $key => &$row) {
             $row['type_id'] = $entry['id'];
             unset($rows[$key]['id']);
         }
         $this->_iaDb->insert($rows);
         $this->_iaDb->resetTable();
     }
 }
开发者ID:kamilklkn,项目名称:subrion,代码行数:20,代码来源:usergroups.php

示例8: snippet

 public static function snippet($text, $length = 600)
 {
     $iaUtil = iaCore::instance()->factory('util');
     iaUtil::loadUTF8Functions();
     // Strip HTML and BB codes
     $pattern = '#(\\[\\w+[^\\]]*?\\]|\\[\\/\\w+\\]|<\\w+[^>]*?>|<\\/\\w+>)#i';
     $text = preg_replace($pattern, '', $text);
     // remove repeated spaces and new lines
     $text = preg_replace('/\\s{2,}/', PHP_EOL, $text);
     $text = trim($text, PHP_EOL);
     if (utf8_strlen($text) > $length) {
         $text = utf8_substr($text, 0, $length);
         $_tmp = utf8_decode($text);
         if (preg_match('#.*([\\.\\s]).*#s', $_tmp, $matches, PREG_OFFSET_CAPTURE)) {
             $end_pos = $matches[1][1];
             $text = utf8_substr($text, 0, $end_pos + 1);
             $text .= ' ...';
         }
     }
     return $text;
 }
开发者ID:TalehFarzaliey,项目名称:subrion,代码行数:21,代码来源:ia.core.sanitize.php

示例9: _postSaveEntry

 protected function _postSaveEntry(array &$entry, array $data, $action)
 {
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     foreach ($this->_iaCore->languages as $code => $language) {
         $title = iaSanitize::tags($data['title'][$code]);
         utf8_is_valid($title) || ($title = utf8_bad_replace($title));
         iaLanguage::addPhrase('usergroup_' . $entry['name'], $title, $code);
     }
     // copy privileges
     if ($data['copy_from']) {
         $this->_iaDb->setTable('acl_privileges');
         $where = '`type_id` = :id AND `type` = :type';
         $this->_iaDb->bind($where, array('id' => (int) $data['copy_from'], 'type' => 'group'));
         $rows = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, $where);
         foreach ($rows as $key => &$row) {
             $row['type_id'] = $this->getEntryId();
             unset($rows[$key]['id']);
         }
         $this->_iaDb->insert($rows);
         $this->_iaDb->resetTable();
     }
 }
开发者ID:rentpad,项目名称:subrion,代码行数:22,代码来源:usergroups.php

示例10: _preSaveEntry

 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     $this->_iaCore->startHook('adminAddMemberValidation');
     $iaAcl = $this->_iaCore->factory('acl');
     $iaField = $this->_iaCore->factory('field');
     $fields = iaField::getAcoFieldsList(iaCore::ADMIN, $this->_itemName);
     // below is the hacky way to force the script to upload files to the appropriate user's folder
     // FIXME
     $activeUser = iaUsers::getIdentity(true);
     $_SESSION[iaUsers::SESSION_KEY] = array('id' => $this->getEntryId(), 'username' => $data['username']);
     list($entry, $error, $this->_messages, ) = $iaField->parsePost($fields, $entry);
     $_SESSION[iaUsers::SESSION_KEY] = $activeUser;
     //
     if ($iaAcl->isAccessible($this->getName(), 'usergroup')) {
         if (isset($data['usergroup_id'])) {
             $entry['usergroup_id'] = array_key_exists($data['usergroup_id'], $this->_userGroups) ? $data['usergroup_id'] : iaUsers::MEMBERSHIP_REGULAR;
         }
     } elseif (iaCore::ACTION_ADD == $action) {
         $entry['usergroup_id'] = iaUsers::MEMBERSHIP_REGULAR;
     }
     if ($error) {
         return false;
     }
     $stmt = '`email` = :email';
     if (iaCore::ACTION_EDIT == $action) {
         if (isset($entry['status']) && $entry['status'] == $this->_iaDb->one('status', iaDb::convertIds((int) $this->getEntryId()))) {
             unset($entry['status']);
         }
         $stmt .= ' AND `id` != ' . (int) $this->getEntryId();
     }
     if ($this->_iaDb->exists($stmt, $entry)) {
         $this->addMessage('error_duplicate_email');
     }
     if ($this->_iaDb->exists('`username` = :username AND `id` != :id', array('username' => $entry['username'], 'id' => $this->getEntryId()))) {
         $this->addMessage('username_already_taken');
     }
     if ($iaAcl->checkAccess($this->getName(), 'password') || iaCore::ACTION_ADD == $action) {
         $this->_password = trim($data['_password']);
         if ($this->_password || !empty($data['_password2'])) {
             $entry['password'] = $this->getHelper()->encodePassword($this->_password);
             iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
             if (empty($entry['password'])) {
                 $this->addMessage('error_password_empty');
             } elseif (!utf8_is_ascii($entry['password'])) {
                 $this->addMessage(iaLanguage::get('password') . ': ' . iaLanguage::get('ascii_required'));
             } elseif ($entry['password'] != $this->getHelper()->encodePassword($data['_password2'])) {
                 $this->addMessage('error_password_match');
             }
         }
     }
     if (empty($data['_password']) && iaCore::ACTION_ADD == $action) {
         $this->addMessage('error_password_empty');
     }
     return !$this->getMessages();
 }
开发者ID:nicefirework,项目名称:subrion,代码行数:55,代码来源:members.php

示例11: array

     if (1 != count($iaCore->requestPath)) {
         return iaView::errorPage(iaView::ERROR_NOT_FOUND);
     }
     $id = (int) $iaCore->requestPath[0];
     $entry = $iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($id));
     if (!$entry) {
         return iaView::errorPage(iaView::ERROR_NOT_FOUND);
     }
     if ($entry['member_id'] != iaUsers::getIdentity()->id) {
         return iaView::errorPage(iaView::ERROR_FORBIDDEN);
     }
 }
 if (isset($_POST['data-blog-entry'])) {
     $result = false;
     $messages = array();
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     $entry['title'] = $_POST['title'];
     utf8_is_valid($entry['title']) || ($entry['title'] = utf8_bad_replace($entry['title']));
     if (empty($entry['title'])) {
         $messages[] = iaLanguage::get('title_is_empty');
     }
     $entry['body'] = $_POST['body'];
     utf8_is_valid($entry['body']) || ($entry['body'] = utf8_bad_replace($entry['body']));
     if (empty($entry['body'])) {
         $messages[] = iaLanguage::getf('field_is_empty', array('field' => iaLanguage::get('body')));
     }
     $entry['alias'] = $iaBlog->titleAlias(empty($_POST['alias']) ? $entry['title'] : $_POST['alias']);
     if (!$messages) {
         if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
             $iaPicture = $iaCore->factory('picture');
             $info = array('image_width' => 1000, 'image_height' => 750, 'thumb_width' => 250, 'thumb_height' => 250, 'resize_mode' => iaPicture::CROP);
开发者ID:UzielSilva,项目名称:subrion,代码行数:31,代码来源:index.php

示例12: _queryPage

 private function _queryPage(&$iaView)
 {
     if (isset($_SESSION['queries'])) {
         $iaView->assign('history', $_SESSION['queries']);
     }
     if (isset($_POST['exec_query'])) {
         iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
         $sql = $_POST['query'];
         $outerData = '';
         utf8_is_valid($sql) || ($sql = utf8_bad_replace($sql));
         $queries = false === strpos($sql, ';' . PHP_EOL) ? array($sql) : explode(";\r\n", $sql);
         foreach ($queries as $key => $sqlQuery) {
             $sql = trim(str_replace('{prefix}', $this->_iaDb->prefix, $sqlQuery));
             $this->_iaCore->startHook('phpAdminBeforeRunSqlQuery', array('query' => $sql));
             $result = $this->_iaDb->query($sql);
             $this->_iaCore->startHook('phpAdminAfterRunSqlQuery');
             $numrows = 0;
             if ($result) {
                 isset($_SESSION['queries']) || ($_SESSION['queries'] = array());
                 if (!in_array($sqlQuery, $_SESSION['queries'])) {
                     if (count($_SESSION['queries']) >= 5) {
                         array_shift($_SESSION['queries']);
                     }
                     $_SESSION['queries'][] = $sqlQuery;
                 }
                 $numrows = $rows = $this->_iaDb->getNumRows($result);
                 if ($rows) {
                     $rows .= $rows > 1 ? ' rows' : ' row';
                     $this->addMessage("<b>Query OK:</b> {$rows} selected.", false);
                 } else {
                     $this->addMessage('<b>Query OK:</b> ' . $this->_iaDb->getAffected() . ' rows affected.', false);
                 }
             } else {
                 $this->_error = true;
                 $this->addMessage('<b>Query Failed:</b><br />' . $this->_iaDb->getError());
             }
             if ($numrows) {
                 // get field names
                 $fieldNames = $this->_iaDb->getFieldNames($result);
                 $outerData .= '<table class="table table-hover table-condensed"><thead><tr>';
                 $i = 0;
                 foreach ($fieldNames as $field) {
                     $outerData .= '<th ' . (!$i ? 'class="first"' : '') . '>' . $field->name . '</th>';
                     $i++;
                 }
                 $outerData .= '</tr></thead><tbody>';
                 $numFields = $this->_iaDb->getNumFields($result);
                 while ($row = $this->_iaDb->fetchRow($result)) {
                     $outerData .= '<tr>';
                     for ($i = 0; $i < $numFields; $i++) {
                         $outerData .= '<td' . (!$i ? ' class="first"' : '') . '>' . iaSanitize::html($row[$i]) . '</td>';
                     }
                     $outerData .= '</tr>';
                 }
                 $outerData .= '</tbody></table>';
             }
         }
         $iaView->assign('sql', $sql);
         $iaView->assign('queryOut', $outerData);
     }
     $iaView->assign('tables', $this->getHelper()->getTables());
 }
开发者ID:kamilklkn,项目名称:subrion,代码行数:62,代码来源:database.php

示例13: _preSaveEntry

 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     $entry['item'] = in_array($data['item'], $this->_items) ? $data['item'] : null;
     if (!$entry['item']) {
         $this->addMessage('incorrect_item');
     }
     if ($entry['item'] == iaUsers::getItemName()) {
         if (isset($data['usergroup'])) {
             $entry['usergroup'] = (int) $data['usergroup'];
         }
     }
     if (isset($this->_fields[$entry['item']])) {
         $entry['data'] = array();
         if (!empty($data['fields']) && !$this->getMessages()) {
             $f = $this->_fields[$entry['item']];
             $array = array();
             foreach ($data['fields'] as $field) {
                 if (in_array($field, $f[0])) {
                     $entry['data']['fields'][] = $field;
                     $array[] = $field;
                 } elseif (in_array($field, $f[1])) {
                     $entry['data']['fields'][] = $field;
                 }
             }
             if ($array) {
                 $this->_iaDb->update(array('for_plan' => 1), "`name` IN ('" . implode("','", $entry['data']['fields']) . "')", null, iaField::getTable());
             }
         }
         $entry['data'] = serialize($entry['data']);
     }
     $this->_iaCore->startHook('phpAdminAddPlanValidation');
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     $lang = array('title' => $data['title'], 'description' => $data['description']);
     foreach ($this->_iaCore->languages as $code => $language) {
         if (isset($lang['title'][$code])) {
             if (empty($lang['title'][$code])) {
                 $this->addMessage(iaLanguage::getf('error_lang_title', array('lang' => $language['title'])), false);
             } elseif (!utf8_is_valid($lang['title'][$code])) {
                 $lang['title'][$code] = utf8_bad_replace($lang['title'][$code]);
             }
         }
         if (isset($lang['description'][$code])) {
             if (empty($lang['description'][$code])) {
                 $this->addMessage(iaLanguage::getf('error_lang_description', array('lang' => $language['title'])), false);
             } elseif (!utf8_is_valid($lang['description'][$code])) {
                 $lang['description'][$code] = utf8_bad_replace($lang['description'][$code]);
             }
         }
     }
     $this->_languages = $lang;
     $entry['duration'] = isset($data['duration']) ? $data['duration'] : 0;
     if (!is_numeric($entry['duration'])) {
         $this->addMessage('error_plan_duration');
     }
     $entry['cost'] = (double) $data['cost'];
     $entry['cycles'] = (int) $data['cycles'];
     $entry['unit'] = $data['unit'];
     $entry['status'] = $data['status'];
     $entry['recurring'] = (int) $data['recurring'];
     $entry['expiration_status'] = $data['expiration_status'];
     $this->_iaCore->startHook('phpAdminPlanCommonFieldFilled', array('item' => &$entry));
     $entry['cost'] || ($this->_phraseAddSuccess = 'free_plan_added');
     return !$this->getMessages();
 }
开发者ID:kamilklkn,项目名称:subrion,代码行数:64,代码来源:plans.php

示例14: _save

 private function _save(&$iaView)
 {
     $iaAcl = $this->_iaCore->factory('acl');
     if (!$iaAcl->checkAccess($iaView->name() . iaAcl::SEPARATOR . iaCore::ACTION_EDIT)) {
         return iaView::accessDenied();
     }
     $where = "`type` != 'hidden' " . ($this->_type ? 'AND `custom` = 1' : '');
     $params = $this->_iaDb->keyvalue(array('name', 'type'), $where, iaCore::getConfigTable());
     // correct admin dashboard URL generation
     $adminPage = $this->_iaCore->get('admin_page');
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     $messages = array();
     $error = false;
     if ($_POST['v'] && is_array($_POST['v'])) {
         $values = $_POST['v'];
         $this->_iaCore->startHook('phpConfigurationChange', array('configurationValues' => &$values));
         $this->_iaDb->setTable(iaCore::getConfigTable());
         foreach ($values as $key => $value) {
             $s = strpos($key, '_items_enabled');
             if ($s !== false) {
                 $p = $this->_iaCore->get($key, '', !is_null($this->_type));
                 $array = $p ? explode(',', $p) : array();
                 $data = array();
                 array_shift($value);
                 if ($diff = array_diff($value, $array)) {
                     foreach ($diff as $item) {
                         array_push($data, array('action' => '+', 'item' => $item));
                     }
                 }
                 if ($diff = array_diff($array, $value)) {
                     foreach ($diff as $item) {
                         array_push($data, array('action' => '-', 'item' => $item));
                     }
                 }
                 $extra = substr($key, 0, $s);
                 $this->_iaCore->startHook('phpPackageItemChangedForPlugin', array('data' => $data), $extra);
             }
             if (is_array($value)) {
                 $value = implode(',', $value);
             }
             if (!utf8_is_valid($value)) {
                 $value = utf8_bad_replace($value);
                 trigger_error('Bad UTF-8 detected (replacing with "?") in configuration', E_USER_NOTICE);
             }
             if (self::TYPE_IMAGE == $params[$key]) {
                 if (isset($_POST['delete'][$key])) {
                     $value = '';
                 } elseif (!empty($_FILES[$key]['name'])) {
                     if (!(bool) $_FILES[$key]['error']) {
                         if (@is_uploaded_file($_FILES[$key]['tmp_name'])) {
                             $ext = strtolower(utf8_substr($_FILES[$key]['name'], -3));
                             // if jpeg
                             if ($ext == 'peg') {
                                 $ext = 'jpg';
                             }
                             if (!array_key_exists(strtolower($_FILES[$key]['type']), $this->_imageTypes) || !in_array($ext, $this->_imageTypes, true) || !getimagesize($_FILES[$key]['tmp_name'])) {
                                 $error = true;
                                 $messages[] = iaLanguage::getf('file_type_error', array('extension' => implode(', ', array_unique($this->_imageTypes))));
                             } else {
                                 if ($this->_iaCore->get($key) && file_exists(IA_UPLOADS . $this->_iaCore->get($key))) {
                                     iaUtil::deleteFile(IA_UPLOADS . $this->_iaCore->get($key));
                                 }
                                 $value = $fileName = $key . '.' . $ext;
                                 @move_uploaded_file($_FILES[$key]['tmp_name'], IA_UPLOADS . $fileName);
                                 @chmod(IA_UPLOADS . $fileName, 0777);
                             }
                         }
                     }
                 } else {
                     $value = $this->_iaCore->get($key, '', !is_null($this->_type));
                 }
             }
             if ($this->_type) {
                 $where = sprintf("`name` = '%s' AND `type` = '%s' AND `type_id` = %d", $key, $this->_type, $this->_typeId);
                 $this->_iaDb->setTable(iaCore::getCustomConfigTable());
                 if ($_POST['c'][$key]) {
                     $values = array('name' => $key, 'value' => $value, 'type' => $this->_type, 'type_id' => $this->_typeId);
                     if ($this->_iaDb->exists($where)) {
                         unset($values['value']);
                         $this->_iaDb->bind($where, $values);
                         $this->_iaDb->update(array('value' => $value), $where);
                     } else {
                         $this->_iaDb->insert($values);
                     }
                 } else {
                     $this->_iaDb->delete($where);
                 }
                 $this->_iaDb->resetTable();
             } else {
                 $this->_iaDb->update(array('value' => $value), iaDb::convertIds($key, 'name'));
             }
         }
         $this->_iaDb->resetTable();
         $this->_iaCore->iaCache->clearAll();
     }
     if (!$error) {
         $iaView->setMessages(iaLanguage::get('saved'), iaView::SUCCESS);
         if (isset($_POST['param']['admin_page']) && $_POST['param']['admin_page'] != $adminPage) {
             iaUtil::go_to(IA_URL . $_POST['param']['admin_page'] . '/configuration/general/');
         }
//.........这里部分代码省略.........
开发者ID:kamilklkn,项目名称:subrion,代码行数:101,代码来源:configuration.php

示例15: parsePost

 public function parsePost(array $fields, $previousValues = null)
 {
     $iaCore =& $this->iaCore;
     $error = false;
     $messages = array();
     $invalidFields = array();
     $item = array();
     $data =& $_POST;
     // access to the data source by link
     if (iaCore::ACCESS_ADMIN == $this->iaCore->getAccessType()) {
         if (isset($data['sponsored'])) {
             $item['sponsored'] = (int) $data['sponsored'];
             $item['sponsored_plan_id'] = $item['sponsored'] ? (int) $data['plan_id'] : 0;
             $item['sponsored_start'] = $item['sponsored'] ? date(iaDb::DATETIME_SHORT_FORMAT) : null;
             $item['sponsored_end'] = $item['sponsored'] ? $data['sponsored_end'] : null;
         }
         if (isset($data['featured'])) {
             $item['featured'] = (int) $data['featured'];
             if ($item['featured']) {
                 if (isset($data['featured_end']) && $data['featured_end']) {
                     $item['featured_start'] = date(iaDb::DATETIME_SHORT_FORMAT);
                     $item['featured_end'] = iaSanitize::html($data['featured_end']);
                 } else {
                     $error = true;
                     $messages[] = iaLanguage::get('featured_status_finished_date_is_empty');
                     $invalidFields[] = 'featured_end';
                 }
             } else {
                 $item['featured_start'] = null;
                 $item['featured_end'] = null;
             }
         }
         if (isset($data['status'])) {
             $item['status'] = iaSanitize::html($data['status']);
         }
         if (isset($data['date_added'])) {
             $time = strtotime($data['date_added']);
             if (!$time) {
                 $error = true;
                 $messages[] = iaLanguage::get('added_date_is_incorrect');
             } elseif ($time > time()) {
                 $error = true;
                 $messages[] = iaLanguage::get('future_date_specified_for_added_date');
             } else {
                 $item['date_added'] = date(iaDb::DATETIME_SHORT_FORMAT, $time);
             }
         }
         if (isset($data['owner'])) {
             if (empty($data['owner'])) {
                 $error = true;
                 $messages[] = iaLanguage::get('owner_is_not_specified');
             } else {
                 if ($memberId = $iaCore->iaDb->one_bind('id', '`username` = :name OR `fullname` = :name', array('name' => iaSanitize::sql($_POST['owner'])), iaUsers::getTable())) {
                     $item['member_id'] = $memberId;
                 } else {
                     $error = true;
                     $messages[] = iaLanguage::get('incorrect_owner_specified');
                 }
             }
         }
         if (isset($data['locked'])) {
             $item['locked'] = (int) $data['locked'];
         }
     }
     // the code block below filters fields based on parent/dependent structure
     $activeFields = array();
     $parentFields = array();
     foreach ($fields as $field) {
         $activeFields[$field['name']] = $field;
         if (iaField::RELATION_PARENT == $field['relation']) {
             $parentFields[$field['name']] = $field['children'];
         }
     }
     foreach ($parentFields as $fieldName => $dependencies) {
         if (isset($data[$fieldName])) {
             $value = $data[$fieldName];
             foreach ($dependencies as $dependentFieldName => $values) {
                 if (!in_array($value, $values)) {
                     unset($activeFields[$dependentFieldName]);
                 }
             }
         }
     }
     //
     $iaCore->factory('util');
     iaUtil::loadUTF8Functions('validation', 'bad');
     foreach ($activeFields as $fieldName => $field) {
         isset($data[$fieldName]) || ($data[$fieldName] = '');
         // Check the UTF-8 is well formed
         if (!is_array($data[$fieldName]) && !utf8_is_valid($data[$fieldName])) {
             $data[$fieldName] = utf8_bad_replace($data[$fieldName]);
         }
         if ($field['extra_actions']) {
             if (false === eval($field['extra_actions'])) {
                 continue;
                 // make possible to stop further processing of this field by returning FALSE
             }
         }
         if (in_array($field['type'], array(self::TEXT, self::TEXTAREA, self::NUMBER, self::RADIO, self::CHECKBOX, self::COMBO))) {
             if ($field['required']) {
//.........这里部分代码省略.........
开发者ID:nicefirework,项目名称:subrion,代码行数:101,代码来源:ia.core.field.php


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