PHP Функция array_shift - примеры использования

На этой странице представлены лучшие примеры PHP кода для метода array_shift, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
Пример #1
Показать файл Файл: image-replace-matrix.php Проект: behaba/csscaffold
0
function Scaffold_image_replace_matrix($params)
{
    if (preg_match_all('/\\([^)]*?,[^)]*?\\)/', $params, $matches)) {
        foreach ($matches as $key => $original) {
            $new = str_replace(',', '#COMMA#', $original);
            $params = str_replace($original, $new, $params);
        }
    }
    $params = explode(',', $params);
    foreach (array('url', 'width', 'height', 'x', 'y') as $key => $name) {
        ${$name} = trim(str_replace('#COMMA#', ',', array_shift($params)));
    }
    $url = preg_replace('/\\s+/', '', $url);
    $url = preg_replace('/url\\([\'\\"]?|[\'\\"]?\\)$/', '', $url);
    if (!$x) {
        $x = 0;
    }
    if (!$y) {
        $y = 0;
    }
    $path = Scaffold::find_file($url);
    if ($path === false) {
        return false;
    }
    // Make sure theres a value so it doesn't break the css
    if (!$width && !$height) {
        $width = $height = 0;
    }
    // Build the selector
    $properties = "background:url(" . Scaffold::url_path($path) . ") no-repeat {$x}px {$y}px;\n\t\theight:{$height}px;\n\t\twidth:{$width}px;\n\t\tdisplay:block;\n\t\ttext-indent:-9999px;\n\t\toverflow:hidden;";
    return $properties;
}
Пример #2
Показать файл Файл: PantheonAliases.php Проект: pantheon-systems/terminus
0
 /**
  * Constructs a Drush alias for an environment. Used to supply
  *   organizational Drush aliases not provided by the API.
  *
  * @param Environment $environment Environment to create an alias for
  * @return string
  * @throws TerminusException
  */
 private function constructAlias($environment)
 {
     $site_name = $environment->site->get('name');
     $site_id = $environment->site->get('id');
     $env_id = $environment->get('id');
     $db_bindings = $environment->bindings->getByType('dbserver');
     $hostnames = array_keys((array) $environment->getHostnames());
     if (empty($hostnames) || empty($db_bindings)) {
         throw new TerminusException('No hostname entry for {site}.{env}', ['site' => $site_name, 'env' => $env_id], 1);
     }
     $db_binding = array_shift($db_bindings);
     $uri = array_shift($hostnames);
     $db_pass = $db_binding->get('password');
     $db_port = $db_binding->get('port');
     if (strpos(TERMINUS_HOST, 'onebox') !== false) {
         $remote_user = "appserver.{$env_id}.{$site_id}";
         $remote_host = TERMINUS_HOST;
         $db_url = "mysql://pantheon:{$db_pass}@{$remote_host}:{$db_port}";
         $db_url .= '/pantheon';
     } else {
         $remote_user = "{$env_id}.{$site_id}";
         $remote_host = "appserver.{$env_id}.{$site_id}.drush.in";
         $db_url = "mysql://pantheon:{$db_pass}@dbserver.{$environment}.{$site_id}";
         $db_url .= ".drush.in:{$db_port}/pantheon";
     }
     $output = "array(\n    'uri'              => {$uri},\n    'db-url'           => {$db_url},\n    'db-allows-remote' => true,\n    'remote-host'      => {$remote_host},\n    'remote-user'      => {$remote_user},\n    'ssh-options'      => '-p 2222 -o \"AddressFamily inet\"',\n    'path-aliases'     => array(\n      '%files'        => 'code/sites/default/files',\n      '%drush-script' => 'drush',\n    ),\n  );";
     return $output;
 }
Пример #3
Показать файл Файл: default_params.php Проект: severnrescue/web
0
/**
 * Dropdown(select with options) shortcode attribute type generator.
 *
 * @param $settings
 * @param $value
 *
 * @since 4.4
 * @return string - html string.
 */
function vc_dropdown_form_field($settings, $value)
{
    $output = '';
    $css_option = str_replace('#', 'hash-', vc_get_dropdown_option($settings, $value));
    $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
    if (is_array($value)) {
        $value = isset($value['value']) ? $value['value'] : array_shift($value);
    }
    if (!empty($settings['value'])) {
        foreach ($settings['value'] as $index => $data) {
            if (is_numeric($index) && (is_string($data) || is_numeric($data))) {
                $option_label = $data;
                $option_value = $data;
            } elseif (is_numeric($index) && is_array($data)) {
                $option_label = isset($data['label']) ? $data['label'] : array_pop($data);
                $option_value = isset($data['value']) ? $data['value'] : array_pop($data);
            } else {
                $option_value = $data;
                $option_label = $index;
            }
            $selected = '';
            $option_value_string = (string) $option_value;
            $value_string = (string) $value;
            if ('' !== $value && $option_value_string === $value_string) {
                $selected = ' selected="selected"';
            }
            $option_class = str_replace('#', 'hash-', $option_value);
            $output .= '<option class="' . esc_attr($option_class) . '" value="' . esc_attr($option_value) . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>';
        }
    }
    $output .= '</select>';
    return $output;
}
Пример #4
Показать файл Файл: lib.php Проект: pzhu2004/moodle
0
/**
 * Serves assignment feedback and other files.
 *
 * @param mixed $course course or id of the course
 * @param mixed $cm course module or id of the course module
 * @param context $context
 * @param string $filearea
 * @param array $args
 * @param bool $forcedownload
 * @return bool false if file not found, does not return if found - just send the file
 */
function assignfeedback_editpdf_pluginfile($course, $cm, context $context, $filearea, $args, $forcedownload)
{
    global $USER, $DB, $CFG;
    if ($context->contextlevel == CONTEXT_MODULE) {
        require_login($course, false, $cm);
        $itemid = (int) array_shift($args);
        if (!($assign = $DB->get_record('assign', array('id' => $cm->instance)))) {
            return false;
        }
        $record = $DB->get_record('assign_grades', array('id' => $itemid), 'userid,assignment', MUST_EXIST);
        $userid = $record->userid;
        if ($assign->id != $record->assignment) {
            return false;
        }
        // Check is users feedback or has grading permission.
        if ($USER->id != $userid and !has_capability('mod/assign:grade', $context)) {
            return false;
        }
        $relativepath = implode('/', $args);
        $fullpath = "/{$context->id}/assignfeedback_editpdf/{$filearea}/{$itemid}/{$relativepath}";
        $fs = get_file_storage();
        if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
            return false;
        }
        // Download MUST be forced - security!
        send_stored_file($file, 0, 0, true);
        // Check if we want to retrieve the stamps.
    }
}
Пример #5
Показать файл Файл: Application.php Проект: stefanhuber/Robo
0
 public function addCommandsFromClass($className, $passThrough = null)
 {
     $roboTasks = new $className();
     $commandNames = array_filter(get_class_methods($className), function ($m) {
         return !in_array($m, ['__construct']);
     });
     foreach ($commandNames as $commandName) {
         $command = $this->createCommand(new TaskInfo($className, $commandName));
         $command->setCode(function (InputInterface $input) use($roboTasks, $commandName, $passThrough) {
             // get passthru args
             $args = $input->getArguments();
             array_shift($args);
             if ($passThrough) {
                 $args[key(array_slice($args, -1, 1, TRUE))] = $passThrough;
             }
             $args[] = $input->getOptions();
             $res = call_user_func_array([$roboTasks, $commandName], $args);
             if (is_int($res)) {
                 exit($res);
             }
             if (is_bool($res)) {
                 exit($res ? 0 : 1);
             }
             if ($res instanceof Result) {
                 exit($res->getExitCode());
             }
         });
         $this->add($command);
     }
 }
Пример #6
Показать файл Файл: lib.php Проект: nuckey/moodle
0
function workshopform_numerrors_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload) {
    global $DB;

    if ($context->contextlevel != CONTEXT_MODULE) {
        return false;
    }

    require_login($course, true, $cm);

    if ($filearea !== 'description') {
        return false;
    }

    $itemid = (int)array_shift($args); // the id of the assessment form dimension
    if (!$workshop = $DB->get_record('workshop', array('id' => $cm->instance))) {
        send_file_not_found();
    }

    if (!$dimension = $DB->get_record('workshopform_numerrors', array('id' => $itemid ,'workshopid' => $workshop->id))) {
        send_file_not_found();
    }

    // TODO now make sure the user is allowed to see the file
    // (media embedded into the dimension description)

    $fs = get_file_storage();
    $relativepath = implode('/', $args);
    $fullpath = "/$context->id/workshopform_numerrors/$filearea/$itemid/$relativepath";
    if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
        return false;
    }

    // finally send the file
    send_stored_file($file);
}
Пример #7
Показать файл Файл: request.php Проект: NavaINT1876/ccustoms
0
 public function set($var, $value = null)
 {
     // parse variable name
     extract($this->_parse($var));
     if (!empty($name)) {
         // set default hash to method
         if ($hash == 'default') {
             $hash = 'method';
         }
         // set a array value ?
         if (strpos($name, '.') !== false) {
             $parts = explode('.', $name);
             $name = array_shift($parts);
             $array =& $this->_call(array($this->_class, 'getVar'), array($name, array(), $hash, 'array'));
             $val =& $array;
             foreach ($parts as $i => $part) {
                 if (!isset($array[$part])) {
                     $array[$part] = array();
                 }
                 if (isset($parts[$i + 1])) {
                     $array =& $array[$part];
                 } else {
                     $array[$part] = $value;
                 }
             }
             $value = $val;
         }
         $this->_call(array($this->_class, 'setVar'), array($name, $value, $hash));
     }
     return $this;
 }
Пример #8
Показать файл Файл: Boolean.php Проект: arendasistemasintegrados/mateusleme
0
 /**
  * Constructor
  *
  * @param string|array|Zend_Config $options OPTIONAL
  */
 public function __construct($options = null)
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     } elseif (!is_array($options)) {
         $options = func_get_args();
         $temp = array();
         if (!empty($options)) {
             $temp['type'] = array_shift($options);
         }
         if (!empty($options)) {
             $temp['casting'] = array_shift($options);
         }
         if (!empty($options)) {
             $temp['locale'] = array_shift($options);
         }
         $options = $temp;
     }
     if (array_key_exists('type', $options)) {
         $this->setType($options['type']);
     }
     if (array_key_exists('casting', $options)) {
         $this->setCasting($options['casting']);
     }
     if (array_key_exists('locale', $options)) {
         $this->setLocale($options['locale']);
     }
 }
Пример #9
Показать файл Файл: ZineIssueAdminController.php Проект: jhnbrnn/Sloop
0
 protected function route($args)
 {
     $id = array_shift($args);
     $issueId = array_shift($args);
     $issue = $this->zineService->getZineIssue($id, $issueId);
     $this->app->render('admin/admin-zine-issue.html.twig', array('token' => $_SESSION['token'], 'stylesheets' => $this->getStyles(), 'type' => 'zine-issue', 'zineId' => $id, 'issue' => $issue));
 }
Пример #10
Показать файл Файл: REST.php Проект: how/openpasl
0
 /**
  * Parse the incoming request in a RESTful way
  *
  * @param \PASL\Web\Service\Request The request object
  */
 public function parseRequest($oRequest)
 {
     $oRequestData = array();
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'GET':
             $oRequestHash = $_REQUEST;
             break;
         case 'POST':
             $oRequestHash = $_REQUEST;
             break;
         case 'PUT':
             parse_str(file_get_contents("php://input"), $oRequestHash);
             break;
     }
     foreach ($oRequestHash as $val) {
         if (trim($val) != "" && !is_null($val)) {
             array_push($oRequest->oRequestHash, $val);
         }
     }
     $oRequest->requestPayload = $oRequestData;
     $oRequest->method = $oRequest->oRequestHash[2];
     // Grab the method arguments
     $methodArgs = $oRequest->oRequestHash;
     array_shift($methodArgs);
     array_shift($methodArgs);
     array_shift($methodArgs);
     $oRequest->methodArgs = $methodArgs;
     return $oRequest;
 }
Пример #11
Показать файл Файл: ConfigurationController.php Проект: giuseppemorelli/magento-extension
0
 public function importMotorsDataAction()
 {
     $helper = Mage::helper('M2ePro/Component_Ebay_Motors');
     $motorsType = $this->getRequest()->getPost('motors_type');
     if (!$motorsType || empty($_FILES['source']['tmp_name'])) {
         $this->getSession()->addError(Mage::helper('M2ePro')->__('Some of required fields are not filled up.'));
         return $this->_redirect('*/*/index');
     }
     $csvParser = new Varien_File_Csv();
     $tempCsvData = $csvParser->getData($_FILES['source']['tmp_name']);
     $csvData = array();
     $headers = array_shift($tempCsvData);
     foreach ($tempCsvData as $csvRow) {
         $csvData[] = array_combine($headers, $csvRow);
     }
     $added = 0;
     $existedItems = $this->getExistedMotorsItems();
     $connWrite = Mage::getSingleton('core/resource')->getConnection('core/write');
     $tableName = $helper->getDictionaryTable($motorsType);
     foreach ($csvData as $csvRow) {
         if (!($insertsData = $this->getPreparedInsertData($csvRow, $existedItems))) {
             continue;
         }
         $added++;
         $connWrite->insert($tableName, $insertsData);
     }
     $this->_getSession()->addSuccess("Successfully added '{$added}' compatibility records.");
     return $this->_redirect('*/*/index');
 }
Пример #12
Показать файл Файл: RESTDocblockParser.php Проект: helpfulrobot/silverstripe-restassured
0
 function __construct(&$lines, $level)
 {
     $res = array();
     $body = array();
     while (count($lines)) {
         $line = array_shift($lines);
         // Blank lines just get a carriage return added (for markdown) and otherwise ignored
         if (!trim($line)) {
             $body[] = "\n";
             continue;
         }
         // Get the indent
         preg_match('/^(\\s*)/', $line, $match);
         $indent = $match[1];
         // Check to make sure we're still indented
         if (strlen($indent) <= $level) {
             array_unshift($lines, $line);
             break;
         }
         // Check for tag
         if (preg_match('/^@([^\\s]+)(.*)$/', trim($line), $match)) {
             $tag = $match[1];
             $sub = new RESTDocblockParser($lines, strlen($indent));
             $sub['details'] = trim($match[2]);
             if (!isset($res[$tag])) {
                 $res[$tag] = new RESTDocblockParser_Sequence();
             }
             $res[$tag][] = $sub;
         } else {
             $body[] = substr($line, $level > 0 ? $level : 0);
         }
     }
     $res['body'] = Markdown(implode("", $body));
     $this->res = $res;
 }
Пример #13
Показать файл Файл: string.php Проект: NaszvadiG/activecollab_loc
0
 /**
  * Parses a unified or context diff.
  *
  * First param contains the whole diff and the second can be used to force
  * a specific diff type. If the second parameter is 'autodetect', the
  * diff will be examined to find out which type of diff this is.
  *
  * @param string $diff  The diff content.
  * @param string $mode  The diff mode of the content in $diff. One of
  *                      'context', 'unified', or 'autodetect'.
  *
  * @return array  List of all diff operations.
  */
 function diff($diff, $mode = 'autodetect')
 {
     if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') {
         return PEAR::raiseError('Type of diff is unsupported');
     }
     if ($mode == 'autodetect') {
         $context = strpos($diff, '***');
         $unified = strpos($diff, '---');
         if ($context === $unified) {
             return PEAR::raiseError('Type of diff could not be detected');
         } elseif ($context === false || $context === false) {
             $mode = $context !== false ? 'context' : 'unified';
         } else {
             $mode = $context < $unified ? 'context' : 'unified';
         }
     }
     // split by new line and remove the diff header
     $diff = explode("\n", $diff);
     array_shift($diff);
     array_shift($diff);
     if ($mode == 'context') {
         return $this->parseContextDiff($diff);
     } else {
         return $this->parseUnifiedDiff($diff);
     }
 }
Пример #14
Показать файл Файл: wechat.lib.class.php Проект: hacktea8/d_z_s_t_u_d_e_n_t
0
 private function _activeHook($type)
 {
     if (!isset($this->_hooks[$type])) {
         return null;
     }
     $hook =& $this->_hooks[$type];
     global $_G;
     if (!in_array($hook['plugin'], $_G['setting']['plugins']['available'])) {
         return null;
     }
     if (!preg_match("/^[\\w\\_]+\$/i", $hook['plugin']) || !preg_match('/^[\\w\\_\\.]+\\.php$/i', $hook['include'])) {
         return null;
     }
     include_once DISCUZ_ROOT . 'source/plugin/' . $hook['plugin'] . '/' . $hook['include'];
     if (!class_exists($hook['class'], false)) {
         return null;
     }
     if (!isset($this->classes[$hook['class']])) {
         $this->classes[$hook['class']] = new $hook['class']();
     }
     if (!method_exists($this->classes[$hook['class']], $hook['method'])) {
         return null;
     }
     $param = func_get_args();
     array_shift($param);
     return $this->classes[$hook['class']]->{$hook}['method']($param);
 }
Пример #15
Показать файл Файл: placeSplitterRefinery.php Проект: idiscussforum/providence
0
 /**
  *
  */
 public function refine(&$pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options = null)
 {
     $o_log = isset($pa_options['log']) && is_object($pa_options['log']) ? $pa_options['log'] : null;
     // Set place hierarchy
     if ($vs_hierarchy = $pa_item['settings']['placeSplitter_placeHierarchy']) {
         $vn_hierarchy_id = caGetListItemID('place_hierarchies', $vs_hierarchy);
     } else {
         // Default to first place hierarchy
         $t_list = new ca_lists();
         $va_hierarchy_ids = $t_list->getItemsForList('place_hierarchies', array('idsOnly' => true));
         $vn_hierarchy_id = array_shift($va_hierarchy_ids);
     }
     if (!$vn_hierarchy_id) {
         if ($o_log) {
             $o_log->logError(_t('[placeSplitterRefinery] No place hierarchies are defined'));
         }
         return array();
     }
     $pa_options['hierarchyID'] = $vn_hierarchy_id;
     $t_place = new ca_places();
     if ($t_place->load(array('parent_id' => null, 'hierarchy_id' => $vn_hierarchy_id))) {
         $pa_options['defaultParentID'] = $t_place->getPrimaryKey();
     }
     return caGenericImportSplitter('placeSplitter', 'place', 'ca_places', $this, $pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options);
 }
Пример #16
Показать файл Файл: AphrontMySQLiDatabaseConnection.php Проект: billtt/libphutil
0
 protected function rawQueries(array $raw_queries)
 {
     $conn = $this->requireConnection();
     $have_result = false;
     $results = array();
     foreach ($raw_queries as $key => $raw_query) {
         if (!$have_result) {
             // End line in front of semicolon to allow single line comments at the
             // end of queries.
             $have_result = $conn->multi_query(implode("\n;\n\n", $raw_queries));
         } else {
             $have_result = $conn->next_result();
         }
         array_shift($raw_queries);
         $result = $conn->store_result();
         if (!$result && !$this->getErrorCode($conn)) {
             $result = true;
         }
         $results[$key] = $this->processResult($result);
     }
     if ($conn->more_results()) {
         throw new Exception(pht('There are some results left in the result set.'));
     }
     return $results;
 }
Пример #17
Показать файл Файл: StringLength.php Проект: hirentricore/devmagento
0
 /**
  * Sets validator options
  *
  * @param  integer|array|Zend_Config $options
  * @return void
  */
 public function __construct($options = array())
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     } else {
         if (!is_array($options)) {
             $options = func_get_args();
             $temp['min'] = array_shift($options);
             if (!empty($options)) {
                 $temp['max'] = array_shift($options);
             }
             if (!empty($options)) {
                 $temp['encoding'] = array_shift($options);
             }
             $options = $temp;
         }
     }
     if (!array_key_exists('min', $options)) {
         $options['min'] = 0;
     }
     $this->setMin($options['min']);
     if (array_key_exists('max', $options)) {
         $this->setMax($options['max']);
     }
     if (array_key_exists('encoding', $options)) {
         $this->setEncoding($options['encoding']);
     }
 }
Пример #18
Показать файл Файл: Action.php Проект: ronseigel/agent-ohm
0
 /**
  * Translate a phrase
  *
  * @return string
  */
 public function __()
 {
     $args = func_get_args();
     $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->_getRealModuleName());
     array_unshift($args, $expr);
     return AO::app()->getTranslator()->translate($args);
 }
Пример #19
Показать файл Файл: Captcha.php Проект: Yaoming9/Projet-Web-PhP
0
 /**
  * Set captcha adapter
  *
  * @param string|array|Zend_Captcha_Adapter $captcha
  * @param array $options
  */
 public function setCaptcha($captcha, $options = array())
 {
     if ($captcha instanceof Zend_Captcha_Adapter) {
         $instance = $captcha;
     } else {
         if (is_array($captcha)) {
             if (array_key_exists('captcha', $captcha)) {
                 $name = $captcha['captcha'];
                 unset($captcha['captcha']);
             } else {
                 $name = array_shift($captcha);
             }
             $options = array_merge($options, $captcha);
         } else {
             $name = $captcha;
         }
         $name = $this->getPluginLoader(self::CAPTCHA)->load($name);
         if (empty($options)) {
             $instance = new $name();
         } else {
             $r = new ReflectionClass($name);
             if ($r->hasMethod('__construct')) {
                 $instance = $r->newInstanceArgs(array($options));
             } else {
                 $instance = $r->newInstance();
             }
         }
     }
     $this->_captcha = $instance;
     $this->_captcha->setName($this->getName());
     return $this;
 }
Пример #20
Показать файл Файл: UnderscoreArrayFilter.php Проект: linking-arts/furry-goggles
0
 /**
  * Expands a flat array to a nested array.
  *
  * For example, `['0_Foo_Bar' => 'Far']` becomes
  * `[['Foo' => ['Bar' => 'Far']]]`.
  *
  * @param array $environment Array of environment data
  * @return array
  */
 public function __invoke(array $environment)
 {
     $result = array();
     foreach ($environment as $flat => $value) {
         $keys = explode('_', $flat);
         $keys = array_reverse($keys);
         $child = array($keys[0] => $value);
         array_shift($keys);
         foreach ($keys as $k) {
             $child = array($k => $child);
         }
         $stack = array(array($child, &$result));
         while (!empty($stack)) {
             foreach ($stack as $curKey => &$curMerge) {
                 foreach ($curMerge[0] as $key => &$val) {
                     $hasKey = !empty($curMerge[1][$key]);
                     if ($hasKey && (array) $curMerge[1][$key] === $curMerge[1][$key] && (array) $val === $val) {
                         $stack[] = array(&$val, &$curMerge[1][$key]);
                     } else {
                         $curMerge[1][$key] = $val;
                     }
                 }
                 unset($stack[$curKey]);
             }
             unset($curMerge);
         }
     }
     return $result;
 }
Пример #21
Показать файл Файл: Helpers.php Проект: yurykabanov/xsd2blade
0
 public static function buildRoute($route)
 {
     $result = static::snakeCase(array_shift($route));
     return $result . join("", array_map(function ($e) {
         return "['" . Helpers::snakeCase($e) . "']";
     }, $route));
 }
Пример #22
Показать файл Файл: controller.php Проект: dalinhuang/shopexts
0
 function display($tmpl_file, $app_id = null)
 {
     array_unshift($this->_files, $tmpl_file);
     $this->_vars = $this->pagedata;
     if ($p = strpos($tmpl_file, ':')) {
         $object = kernel::service('tpl_source.' . substr($tmpl_file, 0, $p));
         if ($object) {
             $tmpl_file_path = substr($tmpl_file, $p + 1);
             $last_modified = $object->last_modified($tmpl_file_path);
         }
     } else {
         $tmpl_file = realpath(APP_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file);
         $last_modified = filemtime($tmpl_file);
     }
     if (!$last_modified) {
         //无文件
     }
     $compile_id = $this->compile_id($tmpl_file);
     if ($object) {
         $compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path));
     } else {
         $compile_code = $this->_compiler()->compile_file($tmpl_file);
     }
     eval('?>' . $compile_code);
     array_shift($this->_files);
 }
Пример #23
Показать файл Файл: salesforce.php Проект: jimdough/Roadmaster
0
/**
 * Sort input array by $subkey
 * Taken from: http://php.net/manual/en/function.ksort.php
 */
function w2l_sksort(&$array, $subkey = "id", $sort_ascending = false)
{
    if (!is_array($array)) {
        return $array;
    }
    $temp_array = array();
    if (count($array)) {
        $temp_array[key($array)] = array_shift($array);
    }
    foreach ($array as $key => $val) {
        $offset = 0;
        $found = false;
        foreach ($temp_array as $tmp_key => $tmp_val) {
            if (!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) {
                $temp_array = array_merge((array) array_slice($temp_array, 0, $offset), array($key => $val), array_slice($temp_array, $offset));
                $found = true;
            }
            $offset++;
        }
        if (!$found) {
            $temp_array = array_merge($temp_array, array($key => $val));
        }
    }
    if ($sort_ascending) {
        $array = array_reverse($temp_array);
    } else {
        $array = $temp_array;
    }
}
Пример #24
Показать файл Файл: ArrayLogger.php Проект: EnmanuelCode/backend-laravel
0
 /**
  * Add a log entry.
  *
  * @param string $entry
  */
 public function add($entry)
 {
     $this->_log[] = $entry;
     while (count($this->_log) > $this->_size) {
         array_shift($this->_log);
     }
 }
Пример #25
Показать файл Файл: micropayment.php Проект: alexanderTsig/arabic
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $m = $this->getConfig('methods');
     if (@count($m) == 1) {
         $a = new Am_Paysystem_Action_Form(self::URL . $m[0] . '/event/');
     } else {
         $a = new Am_Paysystem_Action_HtmlTemplate_Micropayment($this->getDir(), 'micropayment-confirm.phtml');
         $methods = array();
         if (@count($m)) {
             $a->url = self::URL . $m[0] . '/event/';
             foreach ($m as $title) {
                 $methods[self::URL . $title . '/event/'] = $this->getConfig($title . '.title');
             }
         } else {
             foreach ($this->getConfig() as $k => $v) {
                 if (is_array($v) && !empty($v['title'])) {
                     $methods[self::URL . $k . '/event/'] = $v['title'];
                 }
             }
             $a->url = array_shift(array_keys($methods));
         }
         $a->methods = $methods;
     }
     $a->project = $this->getConfig('project');
     $a->amount = $invoice->first_total * 100;
     $a->freepaymentid = $invoice->public_id;
     $a->seal = md5("project={$a->project}&amount={$a->amount}&freepaymentid={$a->freepaymentid}" . $this->getConfig('key'));
     $result->setAction($a);
 }
Пример #26
Показать файл Файл: PageRouter.inc.php Проект: ramonsodoma/ocs
0
 /**
  * Redirect to user home page (or the role home page if the user has one role).
  * @param $request PKPRequest the request to be routed
  */
 function redirectHome(&$request)
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $user = $request->getUser();
     $userId = $user->getId();
     if ($schedConf =& $this->getContext($request, 2)) {
         // The user is in the sched. conf. context, see if they have one role only
         $roles =& $roleDao->getRolesByUserId($userId, $schedConf->getConferenceId(), $schedConf->getId());
         if (count($roles) == 1) {
             $role = array_shift($roles);
             if ($role->getRoleId() == ROLE_ID_READER) {
                 $request->redirect(null, 'index');
             }
             $request->redirect(null, null, $role->getRolePath());
         } else {
             $request->redirect(null, null, 'user');
         }
     } elseif ($conference =& $this->getContext($request, 1)) {
         // The user is in the conference context, see if they have one role only
         $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
         $roles =& $roleDao->getRolesByUserId($userId, $conference->getId());
         if (count($roles) == 1) {
             $role = array_shift($roles);
             $confPath = $conference->getPath();
             $schedConfPath = 'index';
             if ($role->getSchedConfId()) {
                 $schedConf = $schedConfDao->getSchedConf($role->getSchedConfId());
                 $schedConfPath = $schedConf->getPath();
             }
             if ($role->getRoleId() == ROLE_ID_READER) {
                 $request->redirect($confPath, $schedConfPath, 'index');
             }
             $request->redirect($confPath, $schedConfPath, $role->getRolePath());
         } else {
             $request->redirect(null, null, 'user');
         }
     } else {
         // The user is at the site context, check to see if they are
         // only registered in one conf/SchedConf w/ one role
         $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
         $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
         $roles = $roleDao->getRolesByUserId($userId);
         if (count($roles) == 1) {
             $role = array_shift($roles);
             $confPath = 'index';
             $schedConfPath = 'index';
             if ($role->getConferenceId()) {
                 $conference = $conferenceDao->getConference($role->getConferenceId());
                 isset($conference) ? $confPath = $conference->getPath() : ($confPath = 'index');
             }
             if ($role->getSchedConfId()) {
                 $schedConf = $schedConfDao->getSchedConf($role->getSchedConfId());
                 isset($schedConf) ? $schedConfPath = $schedConf->getPath() : ($schedConfPath = 'index');
             }
             $request->redirect($confPath, $schedConfPath, $role->getRolePath());
         } else {
             $request->redirect('index', 'index', 'user');
         }
     }
 }
Пример #27
Показать файл Файл: AuthentificationLDAP.php Проект: JDemonchaux/glpmr-portail
0
 /**
  * Fonction qui permet de connaitre la classe d'un étudiant
  * @param $username : le nom d'utilisateur AD d'un étudiant
  * @return $classe : la classe de l'étudiant
  */
 public static function getInfosUser($login, $password)
 {
     $user = new User();
     $listeAgent = array();
     $isConnected = AuthentificationLDAP::open($login, $password);
     if ($isConnected) {
         $resultat = ldap_search(self::$connexion, self::$dn, self::$user_filter);
         if (FALSE !== $resultat) {
             $entries = ldap_get_entries(self::$connexion, $resultat);
             foreach ($entries as $unAgent) {
                 // On enlève les user qui servent à rien
                 if (strpos($unAgent['dn'], "OU=Autres")) {
                 } else {
                     array_push($listeAgent, $unAgent['samaccountname'][0]);
                     $user->setPrenom($unAgent[1]["dn"][0]);
                     $user->setNom($unAgent["cn"][0]);
                     //$user->setMail($unAgent["mail"][0]);
                     //$user->setlstGroup($unAgent["memberof"][0]);
                 }
             }
             if ($listeAgent[0] == NULL) {
                 array_shift($listeAgent);
             }
             sort($listeAgent);
         }
     } else {
         // LEVER ERREUR ICI
     }
     return $user;
 }
Пример #28
Показать файл Файл: CsvUploader.php Проект: antic183/php-fileupload-encrypt-json
0
 protected static function checkFileContent()
 {
     $fileContent = file_get_contents(static::$tmpFilepath);
     // check encoding and convert to utf-8 when necessary
     $detectedEncoding = mb_detect_encoding($fileContent, 'UTF-8, ISO-8859-1, WINDOWS-1252', true);
     if ($detectedEncoding) {
         if ($detectedEncoding !== 'UTF-8') {
             $fileContent = iconv($detectedEncoding, 'UTF-8', $fileContent);
         }
     } else {
         echo 'Zeichensatz der CSV-Date stimmt nicht. Der sollte UTF-8 oder ISO-8856-1 sein.';
         return false;
     }
     //prepare data array
     $tmpData = str_getcsv($fileContent, PHP_EOL);
     array_shift($tmpData);
     $preparedData = [];
     $data = array_map(function ($row) use(&$preparedData) {
         $tmpDataArray = str_getcsv($row, ';');
         $tmpKey = trim($tmpDataArray[0]);
         array_shift($tmpDataArray);
         $preparedData[$tmpKey] = $tmpDataArray;
     }, $tmpData);
     // generate json
     $jsonContent = json_encode($preparedData, JSON_HEX_TAG | JSON_HEX_AMP);
     self::$jsonContent = $jsonContent;
     return true;
 }
Пример #29
Показать файл Файл: base.php Проект: uwmadisoncals/Cluster-Plugins
0
 /**
  * Render the field value. Handle both single and repetitive fields.
  *
  * Rendering of a single value is defined in render_single() and multiple values are concatenated by
  * separator provided by get_value_separator().
  *
  * @param bool $echo Echo the output?
  * @return string Rendered HTML.
  * @since 1.9.1
  */
 public function render($echo = false)
 {
     $field_value = $this->field->get_value();
     // Handle all fields as repetitive, we allways have array of individual field values.
     $output_values = array();
     // Optionally limit the number of rendered items
     $max_item_count = $this->get_maximum_item_count();
     $loop_limit = $max_item_count > 0 ? min($max_item_count, count($field_value)) : count($field_value);
     $is_limited_by_max_count = $loop_limit < count($field_value);
     for ($i = 0; $i < $loop_limit; ++$i) {
         $value = array_shift($field_value);
         $output_values[] = $this->render_single($value);
     }
     $output = implode($this->get_value_separator(), $output_values);
     $ellipsis = $this->get_ellipsis();
     $is_limited_by_max_total_length = $this->limit_by_maximum_total_length($output);
     $needs_separator = $is_limited_by_max_count && !$is_limited_by_max_total_length;
     $needs_ellipsis = $is_limited_by_max_count || $is_limited_by_max_total_length;
     if ($needs_separator) {
         $output .= $this->get_value_separator();
     }
     if ($needs_ellipsis) {
         $output .= $ellipsis;
     }
     if ($echo) {
         echo $output;
     }
     return $output;
 }
Пример #30
Показать файл Файл: PooledBatchExecutor.php Проект: sp4ceb4r/shell-command
0
 /**
  * Run each managed process with up to $batchSize in parallel.
  *
  * @return void
  */
 public function start()
 {
     $finished = [];
     $running = [];
     $active = 0;
     while (!empty($this->processes)) {
         while ($active < $this->batchSize && !empty($this->processes)) {
             $p = array_shift($this->processes);
             array_push($running, $p->runAsync());
             $active++;
         }
         foreach ($running as $index => $p) {
             if (!$p->isAlive()) {
                 $active--;
                 array_push($finished, $p);
                 unset($running[$index]);
                 if (!empty($this->processes)) {
                     array_push($running, array_shift($this->processes)->runAsync());
                     $active++;
                 }
             }
         }
         reset($running);
     }
     unset($this->processes);
     $this->processes = $finished;
     unset($finished, $running);
 }