本文整理汇总了PHP中iaUtil类的典型用法代码示例。如果您正苦于以下问题:PHP iaUtil类的具体用法?PHP iaUtil怎么用?PHP iaUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了iaUtil类的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();
}
示例2: _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();
}
示例3: _launch
protected function _launch($id)
{
//$this->getHelper()->run($id);
// implemented via remote request because potentially some package's cron task
// may use front classes which will cause conflicts if executed from backend side.
// otherwise, the only call of iaCore::run() would be enough
$cronUrl = IA_CLEAR_URL . 'cron/?_t&t=' . (int) $id;
iaUtil::getPageContent($cronUrl, 300);
//
$this->_iaCore->iaView->setMessages(iaLanguage::get('scheduled_task_ran'), iaView::SUCCESS);
iaUtil::go_to($this->getPath());
}
示例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;
}
示例5: _gridRead
protected function _gridRead($params)
{
switch ($_POST['action']) {
case 'delete-file':
return $this->_deleteFile($_POST);
case 'remove-installer':
$result = iaUtil::deleteFile(IA_HOME . 'install/modules/module.install.php');
return array('error' => !$result, 'message' => iaLanguage::get($result ? 'deleted' : 'error'));
default:
$result = array();
$this->_iaCore->startHook('phpAdminActionsJsonHandle', array('action' => $_POST['action'], 'output' => &$result));
return $result;
}
}
示例6: smarty_function_preventCsrf
function smarty_function_preventCsrf($params, &$smarty)
{
// support several post forms in the page
$calledTimes = 0;
if (!isset($_SESSION['prevent_csrf']) || !is_array($_SESSION['prevent_csrf'])) {
$_SESSION['prevent_csrf'] = array();
}
$count = count($_SESSION['prevent_csrf']);
if ($count > 30) {
$_SESSION['prevent_csrf'] = isset($_SESSION['prevent_csrf'][$count - 1]) ? array($_SESSION['prevent_csrf'][$count - 1]) : array();
}
$_SESSION['prevent_csrf'][] = $token = iaUtil::generateToken();
$calledTimes++;
return '<input type="hidden" name="prevent_csrf" value="' . $token . '" />';
}
示例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();
}
}
示例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;
}
示例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();
}
}
示例10: createInvoice
/**
* Generates invoice for an item
*
* @param string $title plan title
* @param double $cost plan cost
* @param string $itemName item name
* @param array $itemData item details
* @param string $returnUrl return URL
* @param int $planId plan id
* @param bool $return true redirects to invoice payment URL
*
* @return string
*/
public function createInvoice($title, $cost, $itemName = 'members', $itemData = array(), $returnUrl = '', $planId = 0, $return = false)
{
if (!isset($itemData['id'])) {
$itemData['id'] = 0;
}
$title = empty($title) ? iaLanguage::get('plan_title_' . $planId) : $title;
$title .= $itemData['id'] ? ' - #' . $itemData['id'] : '';
$transactionId = uniqid('t');
$transaction = array('member_id' => (int) (isset($itemData['member_id']) && $itemData['member_id'] ? $itemData['member_id'] : iaUsers::getIdentity()->id), 'item' => $itemName, 'item_id' => $itemData['id'], 'amount' => $cost, 'currency' => $this->iaCore->get('currency'), 'sec_key' => $transactionId, 'status' => self::PENDING, 'plan_id' => $planId, 'return_url' => $returnUrl, 'operation' => $title, 'date' => date(iaDb::DATETIME_FORMAT));
$result = (bool) $this->iaDb->insert($transaction, null, $this->getTable());
$return || iaUtil::go_to(IA_URL . 'pay' . IA_URL_DELIMITER . $transactionId . IA_URL_DELIMITER);
return $result ? $transactionId : false;
}
示例11: _indexPage
protected function _indexPage(&$iaView)
{
if ('phrases' == $iaView->get('name')) {
iaBreadcrumb::preEnd(iaLanguage::get('languages'), IA_ADMIN_URL . 'languages/');
$iaView->assign('action', 'phrases');
$iaView->display('languages');
return true;
}
$action = isset($this->_iaCore->requestPath[0]) ? $this->_iaCore->requestPath[0] : 'list';
$iaView->assign('action', $action);
switch ($action) {
case 'search':
$pageCaption = iaLanguage::get('search_in_phrases');
break;
case 'download':
$pageCaption = iaLanguage::get('export_language');
if (isset($_POST['lang']) && $_POST['lang'] || isset($this->_iaCore->requestPath[1]) && array_key_exists($this->_iaCore->requestPath[1], $this->_iaCore->languages)) {
$this->_downloadLanguage($iaView);
}
break;
case 'comparison':
$pageCaption = iaLanguage::get('languages_comparison');
$this->_compareLanguages($iaView);
break;
case 'rm':
// TODO: set checkAccess
$this->_removeLanguage($iaView);
iaUtil::go_to($this->getPath());
break;
case 'default':
$this->_setLanguageAsDefault($iaView);
iaUtil::go_to($this->getPath());
break;
case 'import':
$result = $this->_importLanguage($iaView);
iaUtil::go_to($this->getPath() . ($result ? '' : 'download/'));
break;
}
if (isset($pageCaption)) {
iaBreadcrumb::toEnd($pageCaption, IA_SELF);
$iaView->title($pageCaption);
}
}
示例12: _consistencyPage
private function _consistencyPage(&$iaView)
{
if (!empty($_GET['type'])) {
if (in_array($_GET['type'], array('optimize', 'repair'))) {
$tables = $this->getHelper()->getTables();
$type = $_GET['type'];
$query = strtoupper($type) . ' TABLE ';
foreach ($tables as $tableName) {
$query .= '`' . $tableName . '`,';
}
$query = rtrim($query, ',');
$this->_iaDb->query($query);
$iaView->setMessages(iaLanguage::get($type . '_complete'), iaView::SUCCESS);
iaUtil::reload();
} else {
$this->_iaCore->startHook('phpAdminDatabaseConsistencyType', array('type' => $_GET['type']));
}
}
}
示例13: _createJsFile
protected function _createJsFile($file, $type = 'config')
{
$this->iaCore->factory('util');
// required in order the class iaUtil to be loaded
$iaDb =& $this->iaCore->iaDb;
switch ($type) {
case 'lang':
case 'admin_lang':
// get phrases
$stmt = "`code` = :lang AND `category` NOT IN ('tooltip', 'page', :category)";
$iaDb->bind($stmt, array('lang' => $this->iaCore->iaView->language, 'category' => $type == 'admin_lang' ? 'frontend' : iaCore::ADMIN));
$phrases = $iaDb->keyvalue(array('key', 'value'), $stmt, iaLanguage::getTable());
// get list of languages
$languagesList = $iaDb->assoc(array('code', 'title', 'direction', 'flagicon', 'iso' => 'code'), 'admin_lang' == $type ? null : "`status` = 'active'", 'languages');
$fileContent = 'intelli.' . ('admin_lang' == $type ? 'admin.' : '') . 'lang = ' . iaUtil::jsonEncode($phrases) . ';' . 'intelli.languages = ' . iaUtil::jsonEncode($languagesList) . ';';
break;
case 'config':
$stmt = "`private` = 0 && `type` != 'divider' && `config_group` != 'email_templates'";
$config = $iaDb->keyvalue(array('name', 'value'), $stmt, iaCore::getConfigTable());
if (file_exists(IA_INCLUDES . 'custom.inc.php')) {
include IA_INCLUDES . 'custom.inc.php';
}
$config['ia_url'] = IA_CLEAR_URL;
$config['packages'] = $this->iaCore->setPackagesData();
$config['items'] = array();
$config['extras'] = array(array('core', iaLanguage::get('core', 'Core')));
$array = $iaDb->all(array('name', 'title'), "`status` = 'active' ORDER BY `type`", null, null, 'extras');
foreach ($array as $item) {
$config['extras'][] = array($item['name'], $item['title']);
}
$array = $iaDb->onefield('`item`', "`item` != 'transactions'", null, null, 'items');
foreach ($array as $item) {
$config['items'][] = array($item, iaLanguage::get($item, $item));
}
$fileContent = 'intelli.config = ' . iaUtil::jsonEncode($config) . ';';
}
if (isset($fileContent)) {
if ($fh = fopen($file, 'w')) {
fwrite($fh, $fileContent);
fclose($fh);
}
}
}
示例14: _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();
}
示例15: jsonp
public function jsonp($data)
{
$this->iaCore->factory('util');
echo sprintf('%s(%s)', isset($_GET['fn']) ? $_GET['fn'] : '', iaUtil::jsonEncode($data));
exit;
}