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


PHP array_delete函数代码示例

本文整理汇总了PHP中array_delete函数的典型用法代码示例。如果您正苦于以下问题:PHP array_delete函数的具体用法?PHP array_delete怎么用?PHP array_delete使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: array_sort_by_distance_from

function array_sort_by_distance_from($origin, &$ary, &$options = array())
{
    if (!function_exists('compare_distance')) {
        function compare_distance($a, $b)
        {
            if ($a->distance > $b->distance) {
                return 1;
            }
            if ($a->distance < $b->distance) {
                return -1;
            }
            return 0;
        }
    }
    if (array_key_exists('distance_property_name', $options)) {
        $distance_property_name = $options['distance_property_name'];
        array_delete($options, 'distance_property_name');
    } else {
        $distance_property_name = 'distance';
    }
    foreach ($ary as $object) {
        $object->distance = $origin->distance_to($object, $options);
        if (property_exists($object, $distance_property_name)) {
            $object->{$distance_property_name} = $object->distance;
        }
    }
    usort($ary, 'compare_distance');
}
开发者ID:joeymetal,项目名称:v1,代码行数:28,代码来源:array_funcs.php

示例2: test_array_delete

 public function test_array_delete()
 {
     $ar = array('key1' => 'Foo', 'key2' => 'bar');
     $this->assertEquals('Foo', array_delete($ar, 'key1'));
     $this->assertEquals(array('key2' => 'bar'), $ar);
     $this->assertNull(array_delete($ar, 'not_existing'));
     $this->assertEquals(array('key2' => 'bar'), $ar);
 }
开发者ID:jimmytuc,项目名称:php-array-utils,代码行数:8,代码来源:array_test.php

示例3: generate

   /**
    * Generate the widget and return it as string
    *
    * @return string
    */
   public function generate()
   {
       $arrButtons = array('copy', 'drag', 'up', 'down', 'delete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
           $this->import('Database');
           switch (\Input::get($strCommand)) {
               case 'copy':
                   $this->varValue = array_duplicate($this->varValue, \Input::get('cid'));
                   break;
               case 'up':
                   $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, \Input::get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || empty($this->varValue)) {
           $this->varValue = array('');
       }
       // Initialize the tab index
       if (!\Cache::has('tabindex')) {
           \Cache::set('tabindex', 1);
       }
       $tabindex = \Cache::get('tabindex');
       $return = '<ul id="ctrl_' . $this->strId . '" class="tl_listwizard" data-tabindex="' . $tabindex . '">';
       // Add input fields
       for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
           $return .= '
   <li><input type="text" name="' . $this->strId . '[]" class="tl_text" tabindex="' . $tabindex++ . '" value="' . specialchars($this->varValue[$i]) . '"' . $this->getAttributes() . '> ';
           // Add buttons
           foreach ($arrButtons as $button) {
               $class = $button == 'up' || $button == 'down' ? ' class="button-move"' : '';
               if ($button == 'drag') {
                   $return .= \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
               } else {
                   $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '"' . $class . ' title="' . specialchars($GLOBALS['TL_LANG']['MSC']['lw_' . $button]) . '" onclick="Backend.listWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml($button . '.gif', $GLOBALS['TL_LANG']['MSC']['lw_' . $button], 'class="tl_listwizard_img"') . '</a> ';
               }
           }
           $return .= '</li>';
       }
       // Store the tab index
       \Cache::set('tabindex', $tabindex);
       return $return . '
 </ul>';
   }
开发者ID:Mozan,项目名称:core-bundle,代码行数:59,代码来源:ListWizard.php

示例4: deletefile

 public function deletefile($section, $filename)
 {
     if (!isset($this->items[$section])) {
         return false;
     }
     if (!($filename = $this->normfilename($filename))) {
         return false;
     }
     if (false === ($i = array_search($filename, $this->items[$section]['files']))) {
         return false;
     }
     array_delete($this->items[$section]['files'], $i);
     $this->save();
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:14,代码来源:jsmerger.class.php

示例5: establish_connection

 protected static function establish_connection($name)
 {
     if (isset(self::$configurations[$name])) {
         $configuration = self::$configurations[$name];
         if (!isset($configuration['dbname'])) {
             $configuration['dbname'] = array_delete('database', $configuration);
         }
         $adapter = array_delete('adapter', $configuration);
         $username = array_delete('username', $configuration);
         $password = array_delete('password', $configuration);
         $connection_string = $adapter . ':';
         $connection_string .= $adapter == 'sqlite' ? $configuration['dbname'] : array_join_assoc('=', ';', $configuration);
         self::$connections[$name] = new PDO($connection_string, $username, $password);
     } else {
         throw new InvalidArgumentException('Database configuration "' . $name . '" does not exist');
     }
 }
开发者ID:shuber,项目名称:weeports,代码行数:17,代码来源:connection_manager.php

示例6: add

 public function add()
 {
     if (litepublisher::$urlmap->is404) {
         return;
     }
     $url = litepublisher::$urlmap->url;
     $title = litepublisher::$urlmap->context->title;
     foreach ($this->items as $i => $item) {
         if ($url == $item['url']) {
             array_delete($this->items, $i);
             break;
         }
     }
     if (count($this->items) == 10) {
         array_delete($this->items, 9);
     }
     array_insert($this->items, array('url' => $url, 'title' => $title), 0);
     $this->save();
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:19,代码来源:adminhistory.php

示例7: array_delete

function array_delete($ary, $key_to_be_deleted)
{
    $new = array();
    if (is_string($key_to_be_deleted)) {
        if (!array_key_exists($key_to_be_deleted, $ary)) {
            return;
        }
        foreach ($ary as $key => $value) {
            if ($key != $key_to_be_deleted) {
                $new[$key] = $value;
            }
        }
        $ary = $new;
    }
    if (is_array($key_to_be_deleted)) {
        foreach ($key_to_be_deleted as $del) {
            $ary = array_delete($ary, $del);
        }
    }
    return $ary;
}
开发者ID:helenadeus,项目名称:s3db.map,代码行数:21,代码来源:callback.php

示例8: generate

   /**
    * Generate the widget and return it as string
    *
    * @return string
    */
   public function generate()
   {
       $this->import('Database');
       $arrButtons = array('edit', 'copy', 'delete', 'enable', 'drag', 'up', 'down');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
           switch (\Input::get($strCommand)) {
               case 'copy':
                   $this->varValue = array_duplicate($this->varValue, \Input::get('cid'));
                   break;
               case 'up':
                   $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, \Input::get('cid'));
                   break;
           }
       }
       // Get all modules of the current theme
       $objModules = $this->Database->prepare("SELECT id, name, type FROM tl_module WHERE pid=(SELECT pid FROM " . $this->strTable . " WHERE id=?) ORDER BY name")->execute($this->currentRecord);
       // Add the articles module
       $modules[] = array('id' => 0, 'name' => $GLOBALS['TL_LANG']['MOD']['article'][0], 'type' => 'article');
       if ($objModules->numRows) {
           $modules = array_merge($modules, $objModules->fetchAllAssoc());
       }
       $GLOBALS['TL_LANG']['FMD']['article'] = $GLOBALS['TL_LANG']['MOD']['article'];
       // Add the module type (see #3835)
       foreach ($modules as $k => $v) {
           $v['type'] = $GLOBALS['TL_LANG']['FMD'][$v['type']][0];
           $modules[$k] = $v;
       }
       $objRow = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute($this->currentRecord);
       // Show all columns and filter in PageRegular (see #3273)
       $cols = array('header', 'left', 'right', 'main', 'footer');
       $arrSections = trimsplit(',', $objRow->sections);
       // Add custom page sections
       if (!empty($arrSections) && is_array($arrSections)) {
           $cols = array_merge($cols, $arrSections);
       }
       // Get the new value
       if (\Input::post('FORM_SUBMIT') == $this->strTable) {
           $this->varValue = \Input::post($this->strId);
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || !$this->varValue[0]) {
           $this->varValue = array('');
       } else {
           $arrCols = array();
           // Initialize the sorting order
           foreach ($cols as $col) {
               $arrCols[$col] = array();
           }
           foreach ($this->varValue as $v) {
               $arrCols[$v['col']][] = $v;
           }
           $this->varValue = array();
           foreach ($arrCols as $arrCol) {
               $this->varValue = array_merge($this->varValue, $arrCol);
           }
       }
       // Save the value
       if (\Input::get($strCommand) || \Input::post('FORM_SUBMIT') == $this->strTable) {
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           // Reload the page
           if (is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
               $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
           }
       }
       // Initialize the tab index
       if (!\Cache::has('tabindex')) {
           \Cache::set('tabindex', 1);
       }
       $tabindex = \Cache::get('tabindex');
       // Add the label and the return wizard
       $return = '<table id="ctrl_' . $this->strId . '" class="tl_modulewizard">
 <thead>
 <tr>
   <th>' . $GLOBALS['TL_LANG']['MSC']['mw_module'] . '</th>
   <th>' . $GLOBALS['TL_LANG']['MSC']['mw_column'] . '</th>
   <th>&nbsp;</th>
 </tr>
 </thead>
 <tbody class="sortable" data-tabindex="' . $tabindex . '">';
       // Add the input fields
       for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
           $options = '';
           // Add modules
           foreach ($modules as $v) {
               $options .= '<option value="' . specialchars($v['id']) . '"' . static::optionSelected($v['id'], $this->varValue[$i]['mod']) . '>' . $v['name'] . ' [' . $v['type'] . ']</option>';
           }
           $return .= '
//.........这里部分代码省略.........
开发者ID:Mozan,项目名称:core-bundle,代码行数:101,代码来源:ModuleWizard.php

示例9: generate

   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $arrFallback = $this->getFallbackData();
       // Adapt the temporary files
       if (is_array($this->varValue['files']) && !empty($this->varValue['files'])) {
           foreach ($this->varValue['files'] as $v) {
               if (!is_file(TL_ROOT . '/' . $this->getFilePath($v))) {
                   continue;
               }
               $this->varValue[] = array('src' => $v, 'alt' => '', 'desc' => '', 'link' => '', 'translate' => '');
           }
           unset($this->varValue['files']);
       }
       // Merge parent record data
       if ($arrFallback !== false) {
           $blnLanguage = true;
           $this->varValue = Gallery::mergeMediaData($this->varValue, $arrFallback);
       }
       $arrButtons = array('up', 'down', 'delete', 'drag');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
           switch (\Input::get($strCommand)) {
               case 'up':
                   $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, \Input::get('cid'));
                   break;
           }
           \Database::getInstance()->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           \Controller::redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
       }
       $blnIsAjax = \Environment::get('isAjaxRequest');
       $return = '';
       $upload = '';
       if (!$blnIsAjax) {
           $return .= '<div id="ctrl_' . $this->strId . '" class="tl_mediamanager">';
           $extensions = trimsplit(',', $GLOBALS['TL_CONFIG']['validImageTypes']);
           $upload .= '<div id="fineuploader_' . $this->strId . '" class="upload_container"></div>
 <script>
   window.addEvent("domready", function() {
     Isotope.MediaManager.init($("fineuploader_' . $this->strId . '"), "' . $this->strId . '", ' . json_encode($extensions) . ');
   });
 </script>
 <script type="text/template" id="qq-template">
   <div class="qq-uploader-selector qq-uploader">
       <div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
           <span>' . $GLOBALS['TL_LANG']['MSC']['mmDrop'] . '</span>
       </div>
       <div class="qq-upload-button-selector qq-upload-button">
           <div class="tl_submit">' . $GLOBALS['TL_LANG']['MSC']['mmUpload'] . '</div>
       </div>
       <span class="qq-drop-processing-selector qq-drop-processing">
           <span>' . $GLOBALS['TL_LANG']['MSC']['mmProcessing'] . '</span>
           <span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
       </span>
       <ul class="qq-upload-list-selector qq-upload-list">
           <li>
               <div class="qq-progress-bar-container-selector">
                   <div class="qq-progress-bar-selector qq-progress-bar"></div>
               </div>
               <span class="qq-upload-spinner-selector qq-upload-spinner"></span>
               <span class="qq-edit-filename-icon-selector qq-edit-filename-icon"></span>
               <span class="qq-upload-file-selector qq-upload-file"></span>
               <input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
               <span class="qq-upload-size-selector qq-upload-size"></span>
               <span class="qq-upload-status-text-selector qq-upload-status-text"></span>
           </li>
       </ul>
   </div>
 </script>';
       }
       $return .= '<div>';
       if (!is_array($this->varValue) || empty($this->varValue)) {
           return $return . $GLOBALS['TL_LANG']['MSC']['mmNoUploads'] . '</div>' . $upload . (!$blnIsAjax ? '</div>' : '');
       }
       // Add label and return wizard
       $return .= '<table>
 <thead>
 <tr>
   <td class="col_0 col_first">' . $GLOBALS['TL_LANG'][$this->strTable]['mmSrc'] . '</td>
   <td class="col_1">' . $GLOBALS['TL_LANG'][$this->strTable]['mmAlt'] . ' / ' . $GLOBALS['TL_LANG'][$this->strTable]['mmLink'] . '</td>
   <td class="col_2">' . $GLOBALS['TL_LANG'][$this->strTable]['mmDesc'] . '</td>
   <td class="col_3">' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslate'] . '</td>
   <td class="col_4 col_last">&nbsp;</td>
 </tr>
 </thead>
 <tbody class="sortable">';
       // Add input fields
       for ($i = 0, $count = count($this->varValue); $i < $count; $i++) {
           $strFile = $this->getFilePath($this->varValue[$i]['src']);
           if (!is_file(TL_ROOT . '/' . $strFile)) {
//.........这里部分代码省略.........
开发者ID:Aziz-JH,项目名称:core,代码行数:101,代码来源:MediaManager.php

示例10: include_all

function include_all($x)
{
    extract($x);
    #add a few extra variables that will be usefull in the output;
    #x = array('elements'=>, 'element_info'=>, 'user_id'=>, 'db'=>)
    #Example: $data = include_all(compact('elements', 'element_info', 'user_id', 'db'));
    #when there is no resource_class_id, find it from the project where instance was created. WILL ASSUME THAT RESOURCE_CLASS_ID FILLED OUT IS A REQUIREMENT FOR ALL S3DB THAT SHARE RULES
    if ($_REQUEST['project_id'] == '') {
        $project_id = $element_info['project_id'];
    } else {
        $project_id = $_REQUEST['project_id'];
    }
    if (!$model) {
        $model = 'nsy';
    }
    if ($letter == '') {
        $letter = strtoupper(substr($elements, 0, 1));
    }
    if (is_array($GLOBALS['s3map'][$GLOBALS['plurals'][$GLOBALS['s3codes'][$letter]]])) {
        foreach ($GLOBALS['s3map'][$GLOBALS['plurals'][$GLOBALS['s3codes'][$letter]]] as $replace => $with) {
            $element_info[$replace] = $element_info[$with];
        }
    }
    #if element is a class, return the class id
    if ($letter == 'D') {
        $element_info['acl'] = $user_id == '1' ? '222' : (user_is_admin($user_id, $db) ? '212' : (user_is_public($user_id, $db) ? '210' : '211'));
        $element_info['created_by'] = $user_id;
        $element_info['description'] = $GLOBALS['s3db_info']['server']['site_intro'];
        $element_info['name'] = $GLOBALS['s3db_info']['server']['site_title'];
        if ($element_info['deployment_id'] == $GLOBALS['s3db_info']['deployment']['Did']) {
            $element_info['self'] = 1;
        }
    }
    if ($letter == 'G') {
        #echo '<pre>';print_r($x);exit;
        $e = 'groups';
        #$element_info['group_id'] = $element_info['account_id'];
        #$element_info['groupname'] = $element_info['account_uname'];
        #$element_info['acl'] = groupAcl($element_info, $user_id, $db);
        $uid_info = uid($element_info['account_id']);
        $element_info['deployment_id'] = ereg_replace('^D', '', $uid_info['Did']);
        $strictuid = 1;
        $strictsharedwith = 1;
        $uid = 'G' . $element_info['group_id'];
        $shared_with = 'U' . $user_id;
        #$element_info['acl'] = permissionOnResource(compact('user_id', 'shared_with', 'db', 'uid','key','strictsharedwith','strictuid'));
        $element_info['acl'] = groupAcl($element_info, $user_id, $db, $timer);
        if ($timer) {
            $timer->setMarker('Included resource information for ' . $letter);
        }
        #echo '<pre>';print_r($element_info);exit;
    }
    if ($letter == 'U') {
        if ($element_info['account_addr_id'] != '') {
            $sql = "select * from s3db_addr where addr_id = '" . $element_info['account_addr_id'] . "'";
            $fields = array('addr1', 'addr2', 'city', 'state', 'postal_code', 'country');
            $db->query($sql);
            while ($db->next_record()) {
                for ($i = 0; $i < count($fields); $i++) {
                    $element_info[$fields[$i]] = $db->f($fields[$i]);
                }
            }
            $element_info = array_delete($element_info, 'account_addr_id');
        }
        $element_info['user_id'] = $element_info['account_id'];
        $element_info['username'] = $element_info['account_uname'];
        $element_info['login'] = $element_info['account_lid'];
        $element_info['address'] = $element_info['addr1'];
        $uid_info = uid($element_info['account_id']);
        $element_info['deployment_id'] = ereg_replace('^D', '', $uid_info['Did']);
        if ($user_id != '1' && $element_info['created_by'] != $user_id && $element_info['account_id'] != $user_id) {
            #if user is not seing himself and user is not admin and user was not the creator of element, then hide address, email, phone, etc.
            $keys2Remove = array('account_email' => '', 'account_phone' => '', 'addr1' => '', 'addr2' => '', 'city' => '', 'state' => '', 'postal_code' => '', 'country' => '');
            if (is_array($element_info)) {
                $element_info = array_diff_key($element_info, $keys2Remove);
            }
        }
        if ($user_id != '1' && $element_info['created_by'] != $user_id && $user_id != $element_info['account_id']) {
            if (is_array($element_info)) {
                $element_info = array_diff_key($element_info, array('account_type' => '', 'account_status' => ''));
            }
        } else {
            //if this user has been created with a filter, what is that filter
            $permission_info = array('uid' => 'U' . $element_info['created_by'], 'shared_with' => 'U' . $element_info['account_id']);
            $hp = has_permission($permission_info, $db);
            if ($hp) {
                $element_info['filter'] = $hp;
            }
        }
        if (is_array($element_info)) {
            $element_info = array_diff_key($element_info, array('account_pwd' => ''));
        }
        $user_id_who_asks = $user_id;
        $uid = 'U' . $element_info['user_id'];
        $shared_with = $user_id_who_asks;
        $strictuid = 1;
        $strictsharedwith = 1;
        $onPermissions = compact('user_id', 'shared_with', 'db', 'uid', 'key', 'strictsharedwith', 'strictuid');
        if ($element_info['acl'] == '') {
            $element_info['acl'] = userAcl(compact('key', 'element_info', 'user_id_who_asks', 'db'));
//.........这里部分代码省略.........
开发者ID:helenadeus,项目名称:s3db.map,代码行数:101,代码来源:URIaction.php

示例11: generate

    /**
     * Generate the widget and return it as string
     * @return string
     */
    public function generate()
    {
        $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/isotope/html/backend.js';
        $this->import('Database');
        //allows us to set which buttons can be enabled for this widget.
        /*foreach($this->enabledFunctions as $v)
        		{
        			$arrButtons[] = $v;
        		}*/
        $strCommand = 'cmd_' . $this->strField;
        // Change the order
        if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
            switch ($this->Input->get($strCommand)) {
                case 'copy':
                    $this->varValue = array_duplicate($this->varValue, $this->Input->get('cid'));
                    break;
                case 'up':
                    $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                    break;
                case 'down':
                    $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                    break;
                case 'delete':
                    $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                    break;
            }
        }
        $objTaxClasses = $this->Database->execute("SELECT id, name FROM tl_iso_tax_class");
        if ($objTaxClasses->numRows) {
            $arrTaxClasses = $objTaxClasses->fetchAllAssoc();
        }
        if (!is_array($arrTaxClasses) || !count($arrTaxClasses)) {
            $arrTaxClasses = array('');
        }
        // Get new value
        if ($this->Input->post('FORM_SUBMIT') == $this->strTable) {
            $varValue = $this->Input->post($this->strId);
        }
        // Make sure there is at least an empty array
        if (!is_array($this->varValue) || !$this->varValue[0]) {
            //$this->varValue = array('');
        } else {
            /*foreach($this->varValue as $v)
            			{
            
            
            			}*/
        }
        // Save the value
        if ($this->Input->get($strCommand) || $this->Input->post('FORM_SUBMIT') == $this->strTable) {
            $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
            // Reload the page
            if (is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
                $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
            }
        }
        // Add label and return wizard
        $return .= '<table class="tl_optionwizard" id="ctrl_' . $this->strId . '">
  <thead>';
        if (is_array($this->varValue) && count($this->varValue)) {
            $return .= '
    <tr>
      <th><strong>' . $GLOBALS['TL_LANG'][$this->strTable]['opLabel'] . '</strong></th>
      <th><strong>' . $GLOBALS['TL_LANG'][$this->strTable]['opPrice'] . '</strong></th>
      <th><strong>' . $GLOBALS['TL_LANG'][$this->strTable]['opTaxClass'] . '</strong></th>
      <th>&nbsp;</th>
    </tr>
  </thead>
  <tbody>';
            // Add rows
            for ($i = 0; $i < count($this->varValue); $i++) {
                $arrRow = array();
                $arrRow = $this->varValue[$i];
                $blnEditable = false;
                if (is_array($arrRow)) {
                    $blnEditable = true;
                } else {
                    continue;
                }
                $return .= '<tr>';
                $return .= '	<td>' . $this->varValue[$i]['label'] . '<input type="hidden" name="' . $this->strId . '[' . $i . '][label]" id="' . $this->strId . '_label_' . $i . '" value="' . $this->varValue[$i]['label'] . '"></td>';
                $return .= '	<td>' . ($blnEditable ? '<input type="text" name="' . $this->strId . '[' . $i . '][total_price]" id="' . $this->strId . '_total_price_' . $i . '" class="tl_text_3" value="' . specialchars(round($this->varValue[$i]['total_price'], 2)) . '">' : round($this->varValue[$i]['total_price'], 2)) . '</td>';
                $options = '';
                $options = '<option value=""' . $this->optionSelected(NULL, $this->varValue[$i]['tax_class']) . '>-</option>';
                // Add Tax Classes
                foreach ($arrTaxClasses as $v) {
                    $options .= '<option value="' . specialchars($v['id']) . '"' . $this->optionSelected($v['id'], $this->varValue[$i]['tax_class']) . '>' . $v['name'] . '</option>';
                    if ($v['id'] == $this->varValue[$i]['tax_class']) {
                        $strTaxLabel = $v['name'];
                    }
                }
                $return .= '
      <td>' . ($blnEditable ? '<select name="' . $this->strId . '[' . $i . '][tax_class]" class="tl_select_2" onfocus="Backend.getScrollOffset();">' . $options . '</select>' : $strTaxLabel) . '</td>';
                $return .= '<td>';
                if (is_array($arrButtons)) {
                    foreach ($arrButtons as $button) {
//.........这里部分代码省略.........
开发者ID:rburch,项目名称:core-1,代码行数:101,代码来源:SurchargeWizard.php

示例12: selectQuery

function selectQuery($D)
{
    global $timer;
    extract($D);
    if ($s3ql['from'] == 'deployment') {
        $data[0] = array('mothership' => $GLOBALS['s3db_info']['deployment']['mothership'], 'deployment_id' => $GLOBALS['s3db_info']['deployment']['Did'], 'self' => '1', 'description' => $GLOBALS['s3db_info']['server']['site_intro'], 'url' => S3DB_URI_BASE, 'message' => 'Successfully connected to deployment ' . $GLOBALS['s3db_info']['deployment']['Did'] . '. Please provice a key to query the data (for example: ' . ($_SERVER['https'] == 'on' ? 'https://' : 'http://') . $def . S3DB_URI_BASE . '/URI.php?key=xxxxxxxx. For syntax specification and instructions refer to http://s3db.org/');
        #return $data;
    }
    #echo '<pre>';print_r($s3ql);
    if (in_array($s3ql['from'], array_keys($GLOBALS['plurals']))) {
        $s3ql['from'] = $GLOBALS['plurals'][$s3ql['from']];
    }
    #echo '<pre>';print_r($s3ql);exit;
    if ($s3ql['from'] == 'classes') {
        $s3ql['from'] = 'collections';
    }
    if ($s3ql['from'] == 'instances') {
        $s3ql['from'] = 'items';
    }
    if ($s3ql['from'] == 'keys' && $_SESSION['db'] == '') {
        return formatReturn($GLOBALS['error_codes']['not_a_query'], 'Access keys cannot be queried in the API.', $s3ql['format'], '');
        exit;
    }
    if (eregi('^t', $s3ql['shared'])) {
        $shared = true;
        #shared being set to true will tell s3ql that he should not only retrieved uid native to the upstream resource being queried, but those that propagate toward it
        $s3ql = array_delete($s3ql, 'shared');
    }
    if ($s3ql['from'] == 'permission' && $user_id != 1) {
        return formatReturn($GLOBALS['error_codes']['no_permission_message'], 'User cannot query permissions.', $s3ql['format'], '');
        exit;
    }
    if (eregi('^t', $s3ql['shared'])) {
        $shared = true;
        #shared being set to true will tell s3ql that he should not only retrieved uid native to the upstream resource being queried, but those that propagate toward it
        $s3ql = array_delete($s3ql, 'shared');
    }
    if (eregi('complete', $s3ql['display'])) {
        $complete = true;
        #complete will tell s3ql that dictionary terms should be added to the output
        $s3ql = array_delete($s3ql, 'display');
    }
    $target = $s3ql['from'];
    $letter = strtoupper(substr($s3ql['from'], 0, 1));
    $table = strval($target);
    $element = $target;
    $cols = $GLOBALS['dbstruct'][$target];
    $element_id = $s3ql['where'][$GLOBALS['s3ids'][$element]];
    if ($table != '' && !in_array($table, array_keys($GLOBALS['dbstruct']))) {
        return formatReturn($GLOBALS['error_codes']['not_a_query'], 'Not a valid query.', '', $s3ql['format']);
    }
    #manage data in select
    #echo '<pre>';print_r($s3ql);
    #array_keys contains the things to replace and array_values the replacements
    if ($s3ql['select'] != '' && $s3ql['select'] != '*') {
        $s3ql_out = ereg_replace(' ', '', $s3ql['select']);
        #take out all the spaces
        $returnFields = explode(',', $s3ql_out);
        if (!ereg($GLOBALS['s3ids'][$element], $s3ql['select'])) {
            if (ereg('count|max|min', $s3ql['select'])) {
                $SQLfun = ereg_replace("\\(.*\\)", "", $select);
                $SQLfun = ereg_replace("count as count", "count", $SQLfun);
                $s3ql['select'] = '*';
            } else {
                $s3ql['select'] .= ',' . $GLOBALS['s3ids'][$element];
            }
        }
        ##Because of the new code, will also have to add the parent ids to the query
        #$parents = $GLOBALS['inherit'][$GLOBALS['s3ids'][$element]];
        $parents = $GLOBALS['inherit'][$GLOBALS['COREids'][$GLOBALS['singulars'][$element]]];
        ##duuuhhh
        if (is_array($parents)) {
            foreach ($parents as $p) {
                if (!in_array($p, $returnFields)) {
                    $s3ql['select'] .= ',' . str_replace($toreplace, $replacements, $p);
                }
            }
        }
    } else {
        $s3ql['select'] = '*';
    }
    #echo $s3ql['select'];exit;
    #echo '<pre>';print_r($s3ql);exit;
    $toreplace = array_keys($GLOBALS['s3map'][$target]);
    $replacements = array_values($GLOBALS['s3map'][$target]);
    #to replace query str with replacements, remove the spaces and explode by commas
    $select = explode(',', str_replace(' ', '', $s3ql['select']));
    foreach ($select as $s_key => $str_select) {
        if (in_array($str_select, $toreplace)) {
            $select[$s_key] = $replacements[array_search($str_select, $toreplace)];
        }
    }
    #echo '<pre>';print_r($select);exit;
    $s3ql['select'] = implode(',', array_unique($select));
    #$s3ql['select'] = str_replace($toreplace, $replacements, $s3ql['select']);
    #echo '<pre>';print_r($s3ql['select']);
    $select = urldecode($s3ql['select']);
    $select = eregi_replace('uid', $GLOBALS['s3ids'][$element] . ' as uid', $select);
    $select = eregi_replace('uri', $GLOBALS['s3ids'][$element] . ' as uri', $select);
    $select = eregi_replace('(,).*permissionOnResource', '', $select);
//.........这里部分代码省略.........
开发者ID:helenadeus,项目名称:s3db.map,代码行数:101,代码来源:S3QLaction.php

示例13: generate

   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $arrButtons = array('copy', 'up', 'down', 'delete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
           $this->import('Database');
           switch ($this->Input->get($strCommand)) {
               case 'copy':
                   array_insert($this->varValue, $this->Input->get('cid'), array($this->varValue[$this->Input->get('cid')]));
                   break;
               case 'up':
                   $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || !$this->varValue[0]) {
           $this->varValue = array(array(''));
       }
       // Begin table
       $return .= '<table class="tl_optionwizard" id="ctrl_' . $this->strId . '">
 <thead>
   <tr>
     <th>' . $GLOBALS['TL_LANG']['MSC']['ow_key'] . '</th>
     <th>' . $GLOBALS['TL_LANG']['MSC']['ow_value'] . '</th>
     <th>&nbsp;</th>
   </tr>
 </thead>
 <tbody>';
       $tabindex = 0;
       // Add fields
       for ($i = 0; $i < count($this->varValue); $i++) {
           $return .= '
   <tr>
     <td><input type="text" name="' . $this->strId . '[' . $i . '][key]" id="' . $this->strId . '_key_' . $i . '" class="tl_text_2" tabindex="' . ++$tabindex . '" value="' . specialchars($this->varValue[$i]['key']) . '"></td>
     <td><input type="text" name="' . $this->strId . '[' . $i . '][value]" id="' . $this->strId . '_value_' . $i . '" class="tl_text_2" tabindex="' . ++$tabindex . '" value="' . specialchars($this->varValue[$i]['value']) . '"></td>';
           // Add row buttons
           $return .= '
     <td style="white-space:nowrap; padding-left:3px;">';
           foreach ($arrButtons as $button) {
               $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '" onclick="Backend.keyValueWizard(this, \'' . $button . '\', \'ctrl_' . $this->strId . '\'); return false;">' . $this->generateImage($button . '.gif', $GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '</a> ';
           }
           $return .= '</td>
   </tr>';
       }
       return $return . '
 </tbody>
 </table>';
   }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:62,代码来源:KeyValueWizard.php

示例14: generate

   /**
    * Generate the widget and return it as string
    *
    * @return string
    */
   public function generate()
   {
       $arrColButtons = array('ccopy', 'cmovel', 'cmover', 'cdelete');
       $arrRowButtons = array('rcopy', 'rdrag', 'rup', 'rdown', 'rdelete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
           $this->import('Database');
           switch (\Input::get($strCommand)) {
               case 'ccopy':
                   for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
                       $this->varValue[$i] = array_duplicate($this->varValue[$i], \Input::get('cid'));
                   }
                   break;
               case 'cmovel':
                   for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
                       $this->varValue[$i] = array_move_up($this->varValue[$i], \Input::get('cid'));
                   }
                   break;
               case 'cmover':
                   for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
                       $this->varValue[$i] = array_move_down($this->varValue[$i], \Input::get('cid'));
                   }
                   break;
               case 'cdelete':
                   for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
                       $this->varValue[$i] = array_delete($this->varValue[$i], \Input::get('cid'));
                   }
                   break;
               case 'rcopy':
                   $this->varValue = array_duplicate($this->varValue, \Input::get('cid'));
                   break;
               case 'rup':
                   $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                   break;
               case 'rdown':
                   $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                   break;
               case 'rdelete':
                   $this->varValue = array_delete($this->varValue, \Input::get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || empty($this->varValue)) {
           $this->varValue = array(array(''));
       }
       // Initialize the tab index
       if (!\Cache::has('tabindex')) {
           \Cache::set('tabindex', 1);
       }
       $tabindex = \Cache::get('tabindex');
       // Begin the table
       $return = '<div id="tl_tablewizard">
 <table id="ctrl_' . $this->strId . '" class="tl_tablewizard">
 <thead>
   <tr>';
       // Add column buttons
       for ($i = 0, $c = count($this->varValue[0]); $i < $c; $i++) {
           $return .= '
     <td style="text-align:center; white-space:nowrap">';
           // Add column buttons
           foreach ($arrColButtons as $button) {
               $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_' . $button]) . '" onclick="Backend.tableWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml(substr($button, 1) . '.gif', $GLOBALS['TL_LANG']['MSC']['tw_' . $button], 'class="tl_tablewizard_img"') . '</a> ';
           }
           $return .= '</td>';
       }
       $return .= '
     <td></td>
   </tr>
 </thead>
 <tbody class="sortable" data-tabindex="' . $tabindex . '">';
       // Add rows
       for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
           $return .= '
   <tr>';
           // Add cells
           for ($j = 0, $d = count($this->varValue[$i]); $j < $d; $j++) {
               $return .= '
     <td class="tcontainer"><textarea name="' . $this->strId . '[' . $i . '][' . $j . ']" class="tl_textarea noresize" tabindex="' . $tabindex++ . '" rows="' . $this->intRows . '" cols="' . $this->intCols . '"' . $this->getAttributes() . '>' . specialchars($this->varValue[$i][$j]) . '</textarea></td>';
           }
           $return .= '
     <td style="white-space:nowrap">';
           // Add row buttons
           foreach ($arrRowButtons as $button) {
               $class = $button == 'rup' || $button == 'rdown' ? ' class="button-move"' : '';
               if ($button == 'rdrag') {
                   $return .= \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
               } else {
                   $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '"' . $class . ' title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_' . $button]) . '" onclick="Backend.tableWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml(substr($button, 1) . '.gif', $GLOBALS['TL_LANG']['MSC']['tw_' . $button], 'class="tl_tablewizard_img"') . '</a> ';
               }
           }
           $return .= '</td>
//.........这里部分代码省略.........
开发者ID:bytehead,项目名称:contao-core,代码行数:101,代码来源:TableWizard.php

示例15: fix

 public static function fix()
 {
     $widgets = twidgets::i();
     foreach ($widgets->classes as $classname => &$items) {
         foreach ($items as $i => $item) {
             if (!isset($widgets->items[$item['id']])) {
                 unset($items[$i]);
             }
         }
     }
     $views = tviews::i();
     foreach ($views->items as &$viewitem) {
         if ($viewitem['id'] != 1 && !$viewitem['customsidebar']) {
             continue;
         }
         unset($sidebar);
         foreach ($viewitem['sidebars'] as &$sidebar) {
             for ($i = count($sidebar) - 1; $i >= 0; $i--) {
                 //echo $sidebar[$i]['id'], '<br>';
                 if (!isset($widgets->items[$sidebar[$i]['id']])) {
                     array_delete($sidebar, $i);
                 }
             }
         }
     }
     $views->save();
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:27,代码来源:admin.widgets.class.php


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