コード例 #1
0
ファイル: General.php プロジェクト: shankarbala33/snippets
 /**
  * To Compare the array of items to find any changes are happened.
  *
  * @param array $source1 Set Of Array on Before Changes
  * @param array $source2 Set Of Array on After Changes
  * @param string $search type of search
  * @return bool True No Difference | False Has Difference
  */
 public static function checkArrayDifference($source1, $source2, $search)
 {
     if (count($source1) == 0 and count($source2) == 0) {
         return true;
     }
     if ($search == 'all') {
         loop:
         if (count($source1) == 0) {
             return true;
         }
         if (count($source1) != count($source2)) {
             return false;
         }
         $last_bfr = array_last($source1);
         $last_aft = array_last($source2);
         if (!empty(array_diff($last_bfr, $last_aft))) {
             return false;
         } else {
             array_pop($source1);
             array_pop($source2);
             goto loop;
         }
     }
     return true;
 }
コード例 #2
0
 /**
  * Get the default transformer class for the model.
  *
  * @return string
  */
 protected function getDefaultTransformerNamespace()
 {
     $parts = explode('\\', get_class($this));
     $class = array_last($parts);
     array_forget($parts, array_last(array_keys($parts)));
     return $this->makeTransformer($class, implode('\\', $parts));
 }
コード例 #3
0
ファイル: CallStack.class.php プロジェクト: mbcraft/frozen
 public static function peek()
 {
     if (count(self::$call_stack) === 0) {
         return null;
     }
     return array_last(self::$call_stack);
 }
コード例 #4
0
ファイル: Params.class.php プロジェクト: mbcraft/frozen
 private static function peek()
 {
     if (count(self::$call_stack) === 0) {
         self::push();
     }
     return array_last(self::$call_stack);
 }
コード例 #5
0
ファイル: helpers.php プロジェクト: deargonauten/translaravel
 /**
  * Return an url in the default locale
  *
  * @param $url
  * @return string
  */
 function untranslateURL($url)
 {
     $t = app('translator') ?: new TransLaravel();
     // Parse url
     $arrURL = parse_url($url);
     $segments = explode('/', $arrURL['path']);
     if ($t->isLocale($segments[0])) {
         array_shift($segments);
     }
     if (array_last($segments) == '') {
         array_pop($segments);
     }
     $path = implode('/', $segments);
     $newPath = Languages::whereValue($path);
     if ($newPath->count() == 0) {
         $newPath = $path;
     } else {
         $newPath = $newPath->first()->route;
     }
     $returnURL = '';
     $returnURL .= isset($arrURL['scheme']) ? $arrURL['scheme'] . '://' : '';
     $returnURL .= isset($arrURL['host']) ? $arrURL['host'] : '';
     $returnURL .= isset($arrURL['port']) && $arrURL['port'] != 80 ? ':' . $arrURL['port'] : '';
     $returnURL .= '/' . config('app.fallback_language') . '/' . $newPath;
     $returnURL .= isset($arrURL['query']) ? '?' . $arrURL['query'] : '';
     $returnURL .= isset($arrURL['fragment']) ? '#' . $arrURL['fragment'] : '';
     return str_replace('//', '/', $returnURL);
 }
コード例 #6
0
 /**
  * Authorize a resource action based on the incoming request.
  *
  * @param  string  $model
  * @param  string|null  $name
  * @param  array  $options
  * @param  \Illuminate\Http\Request|null  $request
  * @return \Illuminate\Routing\ControllerMiddlewareOptions
  */
 public function authorizeResource($model, $name = null, array $options = [], $request = null)
 {
     $action = with($request ?: request())->route()->getActionName();
     $map = ['index' => 'view', 'create' => 'create', 'store' => 'create', 'show' => 'view', 'edit' => 'update', 'update' => 'update', 'delete' => 'delete'];
     if (!in_array($method = array_last(explode('@', $action)), array_keys($map))) {
         return new ControllerMiddlewareOptions($options);
     }
     $name = $name ?: strtolower(class_basename($model));
     $model = in_array($method, ['index', 'create', 'store']) ? $model : $name;
     return $this->middleware("can:{$map[$method]},{$model}", $options);
 }
コード例 #7
0
 /**
  * Authorize a resource action based on the incoming request.
  *
  * @param  string  $model
  * @param  string|null  $name
  * @param  array  $options
  * @param  \Illuminate\Http\Request|null  $request
  * @return \Illuminate\Routing\ControllerMiddlewareOptions
  */
 public function authorizeResource($model, $name = null, array $options = [], $request = null)
 {
     $method = array_last(explode('@', with($request ?: request())->route()->getActionName()));
     $map = $this->resourceAbilityMap();
     if (!in_array($method, array_keys($map))) {
         return new ControllerMiddlewareOptions($options);
     }
     if (!in_array($method, ['index', 'create', 'store'])) {
         $model = $name ?: strtolower(class_basename($model));
     }
     return $this->middleware("can:{$map[$method]},{$model}", $options);
 }
コード例 #8
0
ファイル: imagemanip.php プロジェクト: erkie/cowl
 public function setPath($path)
 {
     if (!file_exists($path)) {
         throw new ImageManipFileNotFoundException($path);
     }
     $this->path = $path;
     // Try to determine format by file extension
     $format = strtolower(array_last(explode('.', $this->path)));
     if (!in_array($format, self::$FORMATS)) {
         throw new ImageManipUnsupportedFormatException($format);
     }
     $this->format = $format;
 }
コード例 #9
0
ファイル: cowl.php プロジェクト: erkie/cowl
 public static function url($url = null)
 {
     $args = is_array($url) ? $url : func_get_args();
     // Fetch params
     if (is_array(array_last($args))) {
         $params = array_pop($args);
         $params = array_map('urlencode', $params);
         $query_string = '?' . fimplode('%__key__;=%__val__;', $params, '&');
     } else {
         $query_string = '';
     }
     return COWL_BASE . implode('/', $args) . $query_string;
 }
コード例 #10
0
 /**
  * PostsController constructor.
  */
 public function __construct()
 {
     $requestUri = request()->route();
     if ($requestUri) {
         $routeUri = $requestUri->getUri();
         $authorize = null;
         $determine = config('vauth')['authorization']['determine'];
         if (strpos($routeUri, $determine) !== false) {
             $authorize = $routeUri;
         } else {
             $action = array_last(explode('@', request()->route()->getActionName()));
             $authorize = $action . $determine . str_singular($routeUri);
         }
         $this->authorize($authorize);
     }
 }
コード例 #11
0
 /**
  * @param $string
  *
  * @return string
  */
 public function formatAnsi($string)
 {
     $styleStack = [];
     // match all tags like <tag> and </tag>
     $groups = $this->formatParser->parseFormat($string);
     foreach ($groups as $group) {
         $tag = $group[0];
         // <tag> or </tag>
         $styleName = $group[1];
         // tag
         $stylesString = $group[2];
         // stuff like color=red
         // do not process unknown style tags
         if ($styleName !== 'style' && !$this->hasStyle($styleName)) {
             continue;
         }
         // is this a closing tag?
         if (stripos($tag, '/') !== false) {
             // get previous style
             array_pop($styleStack);
             $styleCode = array_last($styleStack);
             if (!$styleCode) {
                 $styleCode = 0;
             }
         } else {
             if ($styleName === 'style') {
                 $style = new ConsoleStyle('style');
             } else {
                 $style = $this->getStyle($styleName);
             }
             if ($style instanceof IConsoleStyle) {
                 // clone style to prevent unwanted
                 // modification on future uses
                 $style = clone $style;
                 $style->parseStyle($stylesString);
                 $styleCode = $style->getStyleCode();
             }
             $styleStack[] = $styleCode;
         }
         // replace first matching tag with the escape sequence;
         $pattern = s('#%s#', preg_quote($tag));
         $escapeSequence = s("[%sm", $styleCode);
         $string = preg_replace($pattern, $escapeSequence, $string, 1);
     }
     $string = $this->formatParser->unescapeTags($string);
     return $string;
 }
コード例 #12
0
ファイル: Route.php プロジェクト: jura-php/jura
 private static function process($route)
 {
     $uses = array_get($route->action, 'uses');
     if (!is_null($uses)) {
         //controller
         if (strpos($uses, "@") > -1) {
             list($name, $method) = explode("@", $uses);
             $pieces = explode(DS, $name);
             $className = $pieces[count($pieces) - 1] = ucfirst(array_last($pieces)) . "Controller";
             $path = J_APPPATH . "controllers" . DS . trim(implode(DS, $pieces), DS) . EXT;
             if (Request::isLocal()) {
                 if (!File::exists($path)) {
                     trigger_error("File <b>" . $path . "</b> doesn't exists");
                 }
             }
             require_once $path;
             $class = new $className();
             if (Request::isLocal()) {
                 if (!method_exists($class, $method)) {
                     trigger_error("Method <b>" . $method . "</b> doesn't exists on class <b>" . $className . "</b>");
                 }
             }
             return call_user_func_array(array(&$class, $method), $route->parameters);
         } else {
             $path = J_APPPATH . "views" . DS . $uses . EXT;
             if (Request::isLocal()) {
                 if (!File::exists($path)) {
                     trigger_error("File <b>" . $path . "</b> doesn't exists");
                 }
             }
             require $path;
         }
     }
     $handler = array_get($route->action, "handler");
     //closure function
     /*$handler = array_first($route->action, function($key, $value)
     		{
     			return is_callable($value);
     		});*/
     if (!is_null($handler) && is_callable($handler)) {
         return call_user_func_array($handler, $route->parameters);
     }
 }
コード例 #13
0
ファイル: Utilities.php プロジェクト: acdha/impphp
/**
 * A replacement error handler with improved debugging features
 * - Backtraces including function parameters will be printed using TextMate URLs when running on localhost
 * - Only the IMP_FATAL_ERROR_MESSAGE will be displayed if IMP_DEBUG is not defined and true
 * - Most errors (all if IMP_DEBUG is true, < E_STRICT otherwise) are fatal to avoid continuing in abnormal situations
 * - Errors will always be recorded using error_log()
 * - MySQL's error will be printed if non-empty
 * - E_STRICT errors in system paths will be ignored to avoid PEAR/PHP5 compatibility issues
 */
function ImpErrorHandler($error, $message, $file, $line, $context)
{
    if (!(error_reporting() & $error)) {
        return;
        // Obey the error_report() level and ignore the error
    }
    if (substr($file, 0, 5) == '/usr/' and $error == E_STRICT) {
        // TODO: come up with a more precise way to avoid reporting E_STRICT errors for PEAR classes
        return;
    }
    $ErrorTypes = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error');
    $ErrorType = isset($ErrorTypes[$error]) ? $ErrorTypes[$error] : 'Unknown';
    // If IMP_DEBUG is defined we make everything fatal - otherwise we abort for anything else than an E_STRICT:
    $fatal = (defined("IMP_DEBUG") and IMP_DEBUG) ? true : $error != E_STRICT;
    $dbt = debug_backtrace();
    assert($dbt[0]['function'] == __FUNCTION__);
    array_shift($dbt);
    // Remove our own entry from the backtrace
    if (defined('IMP_DEBUG') and IMP_DEBUG) {
        print '<div class="Error">';
        print "<p><b>{$ErrorType}</b> at ";
        generate_debug_source_link($file, $line, $message);
        print "</p>";
        if (function_exists('mysql_errno') and mysql_errno() > 0) {
            print '<p>Last MySQL error #' . mysql_errno() . ': <code>' . mysql_error() . '</code></p>';
        }
        generate_debug_backtrace($dbt);
        phpinfo(INFO_ENVIRONMENT | INFO_VARIABLES);
        print '</div>';
    } elseif (defined('IMP_FATAL_ERROR_MESSAGE')) {
        print "\n\n\n";
        print IMP_FATAL_ERROR_MESSAGE;
        print "\n\n\n";
    }
    error_log(__FUNCTION__ . ": {$ErrorType} in {$file} on line {$line}: " . quotemeta($message) . (!empty($dbt) ? ' (Began at ' . kimplode(array_filter_keys(array_last($dbt), array('file', 'line'))) . ')' : ''));
    if ($fatal) {
        if (!headers_sent()) {
            header("HTTP/1.1 500 {$ErrorType}");
        }
        exit(1);
    }
}
コード例 #14
0
ファイル: staticserver.php プロジェクト: erkie/cowl
 private function parsePath()
 {
     if (empty($this->path) || !strstr($this->path, 'gfx') && !strstr($this->path, 'css') && !strstr($this->path, 'js')) {
         $this->is_file = false;
         return;
     }
     // Check to see if it really exists
     if (file_exists($this->path)) {
         $this->is_file = true;
     } elseif (file_exists(self::$files_dir . $this->path)) {
         $this->path = self::$files_dir . $this->path;
         $this->is_file = true;
     }
     // Get the extension
     $this->type = strtolower(array_last(explode('.', $this->path)));
     // Bad filetype!
     if (in_array($this->type, self::$BAD)) {
         $this->is_file = false;
     }
 }
コード例 #15
0
ファイル: Router.php プロジェクト: jura-php/jura
 public static function restful($uri, $name)
 {
     $methods = array("restIndex#GET#/", "restGet#GET#/(:num)", "restNew#GET#/new", "restCreate#POST#/", "restUpdate#PUT#/(:num)", "restDelete#DELETE#/(:num)");
     $uri = trim($uri, "/");
     $pieces = explode(DS, $name);
     $className = $pieces[count($pieces) - 1] = ucfirst(array_last($pieces)) . "Controller";
     $path = J_APPPATH . "controllers" . DS . trim(implode(DS, $pieces), DS) . EXT;
     if (Request::isLocal()) {
         if (!File::exists($path)) {
             trigger_error("File <b>" . $path . "</b> doesn't exists");
         }
     }
     require $path;
     $instance = new $className();
     foreach ($methods as $method) {
         $method = explode("#", $method);
         if (method_exists($instance, $method[0])) {
             Router::register($method[1], $uri . $method[2], $name . "@" . $method[0]);
         }
     }
 }
コード例 #16
0
ファイル: tab.php プロジェクト: agreements/neofrag-cms
    public function display($index)
    {
        $index = url_title($index);
        $module_name = $this->config->segments_url[0];
        $base_url = implode('/', in_array($index, $segments = array_offset_left($this->config->segments_url)) ? $this->_url_position == 'end' ? array_offset_right($segments) : array_offset_left($segments) : $segments);
        $tabs = array('panes' => array(), 'sections' => array());
        $i = 0;
        foreach ($this->_tabs as $tab) {
            if (isset($tab['url'])) {
                $tab['url'] = url_title($tab['url']);
                $tabs['sections'][] = array('active' => $tab['url'] == $index, 'url' => $tab['url'] == $this->_default_tab ? '' : $tab['url'], 'name' => $tab['name']);
                if ($tab['url'] == $index) {
                    $tabs['panes'][] = array('args' => $tab['args'], 'id' => $tab['url'], 'function' => $tab['function']);
                }
                $i++;
            } else {
                $languages = $this->db->select('code', 'name', 'flag')->from('nf_settings_languages')->order_by('`order`')->get();
                foreach ($languages as $lang) {
                    $code = $index;
                    if ($i == 0) {
                        if ($index != array_last($this->config->segments_url)) {
                            $index = $code = $lang['code'];
                        } else {
                            $code = NULL;
                        }
                    }
                    $tabs['sections'][] = array('active' => $lang['code'] == $code, 'url' => $i == 0 ? '' : $lang['code'], 'name' => '<img src="' . image('flags/' . $lang['flag']) . '" alt="" />' . $lang['name']);
                    if ($lang['code'] == $index) {
                        $tabs['panes'][] = array('args' => array_merge($tab['args'], array($index)), 'id' => $lang['code'], 'function' => $tab['function']);
                    }
                    $i++;
                }
            }
        }
        foreach ($tabs['sections'] as $section) {
            if ($is_good = $section['active']) {
                break;
            }
        }
        if (!isset($is_good) || !$is_good || array_last($this->config->segments_url) == $this->_default_tab) {
            throw new Exception(NeoFrag::UNFOUND);
        }
        $output = '	<div class="tabbable">
						<ul class="nav nav-tabs">';
        foreach ($tabs['sections'] as $section) {
            $output .= '	<li' . ($section['active'] ? ' class="active"' : '') . '><a href="' . url($module_name . '/' . trim($this->_url_position == 'end' ? $base_url . '/' . $section['url'] : $section['url'] . '/' . $base_url, '/') . '.html') . '">' . $section['name'] . '</a></li>';
        }
        $output .= '	</ul>
						<div class="tab-content">';
        $caller = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1]['object'];
        foreach ($tabs['panes'] as $pane) {
            $output .= '	<div class="tab-pane active" id="' . $pane['id'] . '">
								' . (string) $caller->method($pane['function'], $pane['args']) . '
							</div>';
        }
        $output .= '	</div>
					</div>';
        return $output;
    }
コード例 #17
0
ファイル: ImageManagerHelper.php プロジェクト: Okipa/una.app
 /**
  * @param string $html
  * @return mixed|string
  */
 public function replaceLibraryImagesAliasesByRealPath(string $html)
 {
     // we get the library image repository
     $images_library_repo = app(LibraryImageRepositoryInterface::class);
     // we get every img node
     preg_match_all('/<img[^>]+>/i', $html, $results);
     $images_attributes = [];
     foreach ($results[0] as $key => $image_node) {
         // we get the image node attributes
         preg_match_all('/(alt|title|src)=("[^"]*")/i', $image_node, $images_attributes[$image_node]);
         foreach ($images_attributes as $image_attributes) {
             // we get the image src value
             $src = str_replace('"', '', array_first(array_last($image_attributes)));
             // if the file doesn't exists
             if (!is_file($images_library_repo->getModel()->imagePath($src))) {
                 // we replace it by the image src
                 try {
                     $image = $images_library_repo->where('alias', $src)->first();
                     $html = str_replace($src, $images_library_repo->getModel()->imagePath($image->src), $html);
                 } catch (Exception $e) {
                     // we log the error
                     //                        CustomLog::info('No image alias has been found in this HTML content.');
                 }
             }
         }
     }
     return $html;
 }
コード例 #18
0
ファイル: functions.php プロジェクト: bonniebo421/rockhall
function array_last_key($array)
{
    return array_last(array_keys($array));
}
コード例 #19
0
ファイル: plugins.php プロジェクト: erkie/cowl
 public static function makeName($filename)
 {
     $name = preg_replace('/plugin\\.(.*?)\\.php/', '$1', array_last(explode('/', $filename)));
     return str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
 }
コード例 #20
0
ファイル: controller.php プロジェクト: szchkt/leaklog-web
 public function render($view, $format = '')
 {
     if ($view == 'nothing') {
         $this->end_action_output_buffering();
         $this->view_path = '';
         return;
     }
     if (!empty($format)) {
         $this->render_format = $format;
     }
     if (strpos($view, '/') === false) {
         $this->view_path = MODULES_PATH . "{$this->module}/{$this->controller}/{$view}.{$this->render_format}.php";
         $this->render_action = $view;
     } else {
         $this->view_path = MODULES_PATH . "{$view}.{$this->render_format}.php";
         $this->render_action = array_last(explode('/', $view));
     }
 }
コード例 #21
0
ファイル: interface.php プロジェクト: ivladdalvi/racktables
function renderIPForObject($object_id)
{
    function printNewItemTR($default_type, $has_children)
    {
        global $aat;
        printOpFormIntro('add');
        echo '<tr><td>';
        printImageHREF('add', 'allocate', TRUE);
        echo '</td>';
        if ($has_children) {
            echo '<td>&nbsp</td>';
        }
        echo "<td class=tdleft><input type='text' size='10' name='bond_name' tabindex=100></td>\n";
        echo "<td class=tdleft><input type=text name='ip' tabindex=101></td>\n";
        if (getConfigVar('EXT_IPV4_VIEW') == 'yes') {
            echo '<td colspan=2>&nbsp;</td>';
        }
        echo '<td>';
        printSelect($aat, array('name' => 'bond_type', 'tabindex' => 102), $default_type);
        echo '</td><td>&nbsp;</td><td>';
        printImageHREF('add', 'allocate', TRUE, 103);
        echo '</td></tr></form>';
    }
    global $aat;
    $children = getObjectContentsList($object_id);
    $has_children = count($children) ? TRUE : FALSE;
    startPortlet('Allocations');
    echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'><tr>\n";
    echo '<th>&nbsp;</th>';
    if ($has_children) {
        echo '<th>Object</th>';
    }
    echo '<th>OS interface</th>';
    echo '<th>IP address</th>';
    if (getConfigVar('EXT_IPV4_VIEW') == 'yes') {
        echo '<th>network</th>';
        echo '<th>routed by</th>';
    }
    echo '<th>type</th>';
    echo '<th>misc</th>';
    echo '<th>&nbsp;</th>';
    echo '</tr>';
    $alloc_list = '';
    // most of the output is stored here
    $used_alloc_types = array();
    $allocs = getObjectIPAllocations($object_id, TRUE);
    // note how many allocs each object has
    if ($has_children) {
        $alloc_count = array();
        foreach ($allocs as $alloc) {
            $alloc_count[$alloc['object_id']] = isset($alloc_count[$alloc['object_id']]) ? $alloc_count[$alloc['object_id']] + 1 : 1;
        }
        $last_object_id = 0;
    }
    foreach ($allocs as $alloc) {
        if (!isset($used_alloc_types[$alloc['type']])) {
            $used_alloc_types[$alloc['type']] = 0;
        }
        $used_alloc_types[$alloc['type']]++;
        $rendered_alloc = callHook('getRenderedAlloc', $alloc['object_id'], $alloc);
        $alloc_list .= getOutputOf('printOpFormIntro', 'upd', array('ip' => $alloc['addrinfo']['ip']));
        $alloc_list .= "<tr class='{$rendered_alloc['tr_class']}' valign=top>";
        $alloc_list .= '<td>' . getOpLink(array('op' => 'del', 'ip' => $alloc['addrinfo']['ip']), '', 'delete', 'Delete this IP address') . '</td>';
        if ($has_children and $last_object_id != $alloc['object_id']) {
            $rowspan = 1;
            $rowspan = $alloc_count[$alloc['object_id']] > 1 ? 'rowspan="' . $alloc_count[$alloc['object_id']] . '"' : '';
            $object_name = $alloc['object_id'] == $object_id ? $alloc['object_name'] : formatPortLink($alloc['object_id'], $alloc['object_name'], NULL, NULL);
            $alloc_list .= "<td class=tdleft {$rowspan}>{$object_name}</td>";
            $last_object_id = $alloc['object_id'];
        }
        $alloc_list .= "<td class=tdleft><input type='text' name='bond_name' value='{$alloc['osif']}' size=10>" . $rendered_alloc['td_name_suffix'] . '</td>';
        $alloc_list .= $rendered_alloc['td_ip'];
        if (getConfigVar('EXT_IPV4_VIEW') == 'yes') {
            $alloc_list .= $rendered_alloc['td_network'];
            $alloc_list .= $rendered_alloc['td_routed_by'];
        }
        $alloc_list .= '<td>' . getSelect($aat, array('name' => 'bond_type'), $alloc['type']) . '</td>';
        $alloc_list .= $rendered_alloc['td_peers'];
        $alloc_list .= '<td>' . getImageHREF('save', 'Save changes', TRUE) . '</td>';
        $alloc_list .= "</form></tr>\n";
    }
    asort($used_alloc_types, SORT_NUMERIC);
    $most_popular_type = empty($used_alloc_types) ? 'regular' : array_last(array_keys($used_alloc_types));
    if ($list_on_top = getConfigVar('ADDNEW_AT_TOP') != 'yes') {
        echo $alloc_list;
    }
    printNewItemTR($most_popular_type, $has_children);
    if (!$list_on_top) {
        echo $alloc_list;
    }
    echo "</table><br>\n";
    finishPortlet();
}
コード例 #22
0
ファイル: interface.php プロジェクト: xtha/salt
function renderIPForObject($object_id)
{
    function printNewItemTR($default_type)
    {
        global $aat;
        printOpFormIntro('add');
        echo "<tr><td>";
        // left btn
        printImageHREF('add', 'allocate', TRUE);
        echo "</td>";
        echo "<td class=tdleft><input type='text' size='10' name='bond_name' tabindex=100></td>\n";
        // if-name
        echo "<td class=tdleft><input type=text name='ip' tabindex=101></td>\n";
        // IP
        if (getConfigVar('EXT_IPV4_VIEW') == 'yes') {
            echo "<td colspan=2>&nbsp;</td>";
        }
        // network, routed by
        echo '<td>';
        printSelect($aat, array('name' => 'bond_type', 'tabindex' => 102), $default_type);
        // type
        echo "</td><td>&nbsp;</td><td>";
        // misc
        printImageHREF('add', 'allocate', TRUE, 103);
        // right btn
        echo "</td></tr></form>";
    }
    global $aat;
    startPortlet('Allocations');
    echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'><tr>\n";
    echo '<th>&nbsp;</th>';
    echo '<th>OS interface</th>';
    echo '<th>IP address</th>';
    if (getConfigVar('EXT_IPV4_VIEW') == 'yes') {
        echo '<th>network</th>';
        echo '<th>routed by</th>';
    }
    echo '<th>type</th>';
    echo '<th>misc</th>';
    echo '<th>&nbsp;</th>';
    echo '</tr>';
    $alloc_list = '';
    // most of the output is stored here
    $used_alloc_types = array();
    foreach (getObjectIPAllocations($object_id) as $alloc) {
        if (!isset($used_alloc_types[$alloc['type']])) {
            $used_alloc_types[$alloc['type']] = 0;
        }
        $used_alloc_types[$alloc['type']]++;
        $rendered_alloc = callHook('getRenderedAlloc', $object_id, $alloc);
        $alloc_list .= getOutputOf('printOpFormIntro', 'upd', array('ip' => $alloc['addrinfo']['ip']));
        $alloc_list .= "<tr class='{$rendered_alloc['tr_class']}' valign=top>";
        $alloc_list .= "<td>" . getOpLink(array('op' => 'del', 'ip' => $alloc['addrinfo']['ip']), '', 'delete', 'Delete this IP address') . "</td>";
        $alloc_list .= "<td class=tdleft><input type='text' name='bond_name' value='{$alloc['osif']}' size=10>" . $rendered_alloc['td_name_suffix'] . "</td>";
        $alloc_list .= $rendered_alloc['td_ip'];
        if (getConfigVar('EXT_IPV4_VIEW') == 'yes') {
            $alloc_list .= $rendered_alloc['td_network'];
            $alloc_list .= $rendered_alloc['td_routed_by'];
        }
        $alloc_list .= '<td>' . getSelect($aat, array('name' => 'bond_type'), $alloc['type']) . "</td>";
        $alloc_list .= $rendered_alloc['td_peers'];
        $alloc_list .= "<td>" . getImageHREF('save', 'Save changes', TRUE) . "</td>";
        $alloc_list .= "</form></tr>\n";
    }
    asort($used_alloc_types, SORT_NUMERIC);
    $most_popular_type = empty($used_alloc_types) ? 'regular' : array_last(array_keys($used_alloc_types));
    if ($list_on_top = getConfigVar('ADDNEW_AT_TOP') != 'yes') {
        echo $alloc_list;
    }
    printNewItemTR($most_popular_type);
    if (!$list_on_top) {
        echo $alloc_list;
    }
    echo "</table><br>\n";
    finishPortlet();
}
コード例 #23
0
ファイル: upload.php プロジェクト: erkie/cowl
 public function getExtension()
 {
     return strtolower(array_last(explode('.', $this->name)));
 }
コード例 #24
0
ファイル: ArrayTest.php プロジェクト: rafsalvioni/zeus-base
 /**
  * @test
  */
 public function arrayLastTest()
 {
     $array = range(0, 9);
     $this->assertTrue(\array_last($array) === 9 && \array_last([]) === null);
 }
コード例 #25
0
ファイル: baseline.php プロジェクト: Klaudit/layers-css
/**
* Get the last item in an array.
*
* @param $array
*	...
*
* @param $traverseChildArrays
*	If the last item is a child array, treat the stack recursively and find the last non-array value.
*
* @return
*	...
*/
function array_last(array $array = array(), $traverseChildArrays = false)
{
    $result = end($array);
    if ($traverseChildArrays and is_array($result)) {
        $result = array_last($result, true);
    }
    return $result;
}
コード例 #26
0
ファイル: arr.php プロジェクト: tapiau/muyo
<?php

require __DIR__ . '/../debug.php';
require __DIR__ . '/../arr.php';
debug_assert(array_eq(array_first(range(1, 5), 3), [1, 2, 3]));
debug_assert(array_eq(array_initial(range(1, 5), 3), [1, 2]));
//TODO: array_to
debug_assert(array_eq(array_last(range(1, 5), 3), [3, 4, 5]));
//debug_assert( array_eq( array_to( range(1,5), 3 ), [1,2,3] ) );
//debug_assert( array_eq( array_from( range(1,5), 3 ), [3,4,5] ) ); // TODO: array_rest
//debug_assert( array_eq( array_before( range(1,5), 3 ), [1,2] ) );
//debug_assert( array_eq( array_after( range(1,5), 3 ), [4,5] ) );
コード例 #27
0
                    </strong>
                </td>
        	</tr>
        @endif
        @if(!empty($bids))
            @foreach($bids as $one)
                <?php 
$singleLot = empty($__item->lots) || !empty($__item->lots) && sizeof($__item->lots) == 1;
?>

                @if ($__item->procurementMethodType=='aboveThresholdEU')
                    <?php 
$q = false;
if (!empty($__item->qualifications)) {
    $q = array_last($__item->qualifications, function ($k, $qualification) use($lot, $one, $singleLot) {
        return ($singleLot || !$singleLot && !empty($qualification->lotID) && $qualification->lotID == $lot->id) && $qualification->bidID == $one->id;
    });
}
?>
                @endif
                @if ($__item->procurementMethodType!='aboveThresholdEU' || ($__item->procurementMethodType=='aboveThresholdEU' && $q && $q->status!='cancelled'))
                    <tr valign="top">
                        <td>
                            <strong>
                                @if($__item->procurementMethod=='open')
                                    @if(!empty($one->tenderers[0]->identifier->legalName))
                                        {{$one->tenderers[0]->identifier->legalName}}<br>
                                    @elseif(!empty($one->tenderers[0]->name))
                                        {{$one->tenderers[0]->name}}<br>
                                    @endif
                                @elseif($__item->procurementMethod=='limited')
コード例 #28
0
ファイル: ArrayTest.php プロジェクト: weew/helpers-array
 public function test_array_last_returns_default_value()
 {
     $this->assertEquals('baz', array_last([], 'baz'));
 }
コード例 #29
0
ファイル: JenCat.php プロジェクト: gubenkovalik/vgchat
 public static function getFileExtension($fileName)
 {
     return strtolower(array_last(explode(".", $fileName)));
 }
コード例 #30
0
ファイル: arr.php プロジェクト: tapiau/muyo
 /**
  * Returns [$-n..$]
  *
  * @param int $n
  *
  * @return callable
  */
 function array_last_dg($n = 1)
 {
     return function ($array) use($n) {
         return array_last($array, $n);
     };
 }