コード例 #1
1
ファイル: Str.php プロジェクト: huglester/pyrocms-helpers
 /**
  * Truncates a string to the given length.  It will optionally preserve
  * HTML tags if $is_html is set to true.
  *
  * @param   string  $string        the string to truncate
  * @param   int     $limit         the number of characters to truncate too
  * @param   string  $continuation  the string to use to denote it was truncated
  * @param   bool    $is_html       whether the string has HTML
  * @return  string  the truncated string
  */
 public static function truncate($string, $limit, $continuation = '...', $is_html = false)
 {
     $offset = 0;
     $tags = array();
     if ($is_html) {
         // Handle special characters.
         preg_match_all('/&[a-z]+;/i', strip_tags($string), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             if ($match[0][1] >= $limit) {
                 break;
             }
             $limit += static::length($match[0][0]) - 1;
         }
         // Handle all the html tags.
         preg_match_all('/<[^>]+>([^<]*)/', $string, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             if ($match[0][1] - $offset >= $limit) {
                 break;
             }
             $tag = static::sub(strtok($match[0][0], " \t\n\r\v>"), 1);
             if ($tag[0] != '/') {
                 $tags[] = $tag;
             } elseif (end($tags) == static::sub($tag, 1)) {
                 array_pop($tags);
             }
             $offset += $match[1][1] - $match[0][1];
         }
     }
     $new_string = static::sub($string, 0, $limit = min(static::length($string), $limit + $offset));
     $new_string .= static::length($string) > $limit ? $continuation : '';
     $new_string .= count($tags = array_reverse($tags)) ? '</' . implode('></', $tags) . '>' : '';
     return $new_string;
 }
コード例 #2
1
 function addnew()
 {
     if ($_POST) {
         $image = $_FILES['logo'];
         $image_name = $image['name'];
         $image_tmp = $image['tmp_name'];
         $image_size = $image['size'];
         $error = $image['error'];
         $file_ext = explode('.', $image_name);
         $file_ext = strtolower(end($file_ext));
         $allowed_ext = array('jpg', 'jpeg', 'bmp', 'png', 'gif');
         $file_on_server = '';
         if (in_array($file_ext, $allowed_ext)) {
             if ($error === 0) {
                 if ($image_size < 3145728) {
                     $file_on_server = uniqid() . '.' . $file_ext;
                     $destination = './brand_img/' . $file_on_server;
                     move_uploaded_file($image_tmp, $destination);
                 }
             }
         }
         $values = array('name' => $this->input->post('name'), 'description' => $this->input->post('desc'), 'logo' => $file_on_server, 'is_active' => 1);
         if ($this->brand->create($values)) {
             $this->session->set_flashdata('message', 'New Brand added successfully');
         } else {
             $this->session->set_flashdata('errormessage', 'Oops! Something went wrong!!');
         }
         redirect(base_url() . 'brands/');
     }
     $this->load->helper('form');
     $this->load->view('includes/header', array('title' => 'Add Brand'));
     $this->load->view('brand/new_brand');
     $this->load->view('includes/footer');
 }
コード例 #3
1
ファイル: Assets.php プロジェクト: AgelxNash/modx.evo.custom
 /**
  * @param $name
  * @param array $params
  * @return string
  */
 public function registerScript($name, $params)
 {
     $out = '';
     if (!isset($this->modx->loadedjscripts[$name])) {
         $src = $params['src'];
         $remote = strpos($src, "http") !== false;
         if (!$remote) {
             $src = $this->modx->config['site_url'] . $src;
             if (!$this->fs->checkFile($params['src'])) {
                 $this->modx->logEvent(0, 3, 'Cannot load ' . $src, 'Assets helper');
                 return false;
             }
         }
         $type = isset($params['type']) ? $params['type'] : end(explode('.', $src));
         if ($type == 'js') {
             $out = '<script type="text/javascript" src="' . $src . '"></script>';
         } else {
             $out = '<link rel="stylesheet" type="text/css" href="' . $src . '">';
         }
         $this->modx->loadedjscripts[$name] = $params;
     } else {
         $out = false;
     }
     return $out;
 }
コード例 #4
0
ファイル: bug35022.php プロジェクト: badlamer/hhvm
function foo(&$state)
{
    $contentDict = end($state);
    for ($contentDict = end($state); $contentDict !== false; $contentDict = prev($state)) {
        echo key($state) . " => " . current($state) . "\n";
    }
}
コード例 #5
0
ファイル: parseFile.php プロジェクト: uchwyt/obtuse-broccoli
 /**
  * load and parse given file.
  * 
  * @param string $name Name of file to load.
  * 
  * @return IAcitive Loaded activity.
  */
 public function parse($name)
 {
     $file_type = end(explode(".", $name));
     $class = '\\utils\\parser\\' . $file_type;
     $parser = new \utils\parser\context(new $class());
     return $parser->algorithm(DIR_UPLOAD . $name);
 }
コード例 #6
0
ファイル: MetadataContext.php プロジェクト: sidibea/Sylius
 /**
  * @Then I should see the following metadata:
  */
 public function iShouldSeeTheFollowingMetadata(TableNode $metadata)
 {
     /** @var NodeElement $table */
     $table = $this->getSession()->getPage()->find('css', '#content > table');
     /** @var NodeElement $row */
     $row = $table->findAll('css', 'tr')[1];
     /** @var NodeElement[] $columns */
     $columns = $row->findAll('css', 'td');
     $contentIndex = $this->getColumnIndex($table, 'Content');
     /** @var NodeElement $list */
     $list = $columns[$contentIndex];
     foreach ($metadata->getRowsHash() as $key => $value) {
         $currentElement = $list;
         $parts = explode('.', $key);
         foreach ($parts as $part) {
             $currentElement = $currentElement->find('xpath', sprintf('/ul/li[starts-with(normalize-space(.), "%s:")]', $part));
         }
         $exploded = explode(':', $currentElement->getText());
         $text = trim(end($exploded));
         $expectedValue = $value;
         if ('<empty>' === $expectedValue) {
             $expectedValue = 'empty';
         } elseif (false !== strpos($expectedValue, ',')) {
             $expectedValue = str_replace([', ', ','], [' ', ' '], $expectedValue);
         }
         if ($text !== $expectedValue) {
             throw new \Exception(sprintf('Expected "%s", got "%s" (item: "%s", original value: "%s")', $expectedValue, $text, $key, $value));
         }
     }
 }
コード例 #7
0
ファイル: Util.php プロジェクト: rexmac/zf2
 /** Find the greatest key that is less than or equal to a given upper
  * bound, and return the value associated with that key.
  *
  * @param integer|null $maximumKey The upper bound for keys. If null, the
  *        maxiumum valued key will be found.
  * @param array $collection An two-dimensional array of key/value pairs
  *        to search through.
  * @returns mixed The value corresponding to the located key.
  * @throws \Zend\GData\App\Exception Thrown if $collection is empty.
  */
 public static function findGreatestBoundedValue($maximumKey, $collection)
 {
     $found = false;
     $foundKey = $maximumKey;
     // Sanity check: Make sure that the collection isn't empty
     if (sizeof($collection) == 0) {
         throw new Exception("Empty namespace collection encountered.");
     }
     if ($maximumKey === null) {
         // If the key is null, then we return the maximum available
         $keys = array_keys($collection);
         sort($keys);
         $found = true;
         $foundKey = end($keys);
     } else {
         // Otherwise, we optimistically guess that the current version
         // will have a matching namespce. If that fails, we decrement the
         // version until we find a match.
         while (!$found && $foundKey >= 0) {
             if (array_key_exists($foundKey, $collection)) {
                 $found = true;
             } else {
                 $foundKey--;
             }
         }
     }
     // Guard: A namespace wasn't found. Either none were registered, or
     // the current protcol version is lower than the maximum namespace.
     if (!$found) {
         throw new Exception("Namespace compatible with current protocol not found.");
     }
     return $foundKey;
 }
コード例 #8
0
 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     $model = new LoginForm();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $model->attributes = $_POST['LoginForm'];
         // validate user input and redirect to the previous page if valid
         if ($model->validate() && $model->login()) {
             if (end(explode("/", Yii::app()->user->returnUrl)) == 'index.php') {
                 $this->redirect('negociosavenda/');
             } else {
                 $this->redirect(Yii::app()->user->returnUrl);
             }
         } else {
             Yii::app()->user->setFlash('#usr_error', true);
             $this->redirect(array('/negociosavenda'));
         }
     }
     // display the login form
     //$this->render('/layouts/comuns/_loginForm',array('model'=>$model));
 }
コード例 #9
0
 /**
  * Gets the last element of the array
  *
  * @throws StateException in case when empty
  * @return mixed
  */
 function getLast()
 {
     if (!sizeof($this->values)) {
         throw new StateException('empty array');
     }
     return end($this->values);
 }
コード例 #10
0
ファイル: Annotation.php プロジェクト: Ryu0621/SaNaVi
 public function __construct(array $lines)
 {
     $this->lines = array_values($lines);
     $keys = array_keys($lines);
     $this->start = $keys[0];
     $this->end = end($keys);
 }
コード例 #11
0
ファイル: Term.php プロジェクト: SalesOneGit/s1_magento
 /**
  * Load terms and try to sort it by names
  *
  * @return Mage_CatalogSearch_Block_Term
  */
 protected function _loadTerms()
 {
     if (empty($this->_terms)) {
         $this->_terms = array();
         $terms = Mage::getResourceModel('catalogsearch/query_collection')->setPopularQueryFilter(Mage::app()->getStore()->getId())->setPageSize(100)->load()->getItems();
         if (count($terms) == 0) {
             return $this;
         }
         $this->_maxPopularity = reset($terms)->getPopularity();
         $this->_minPopularity = end($terms)->getPopularity();
         $range = $this->_maxPopularity - $this->_minPopularity;
         $range = $range == 0 ? 1 : $range;
         foreach ($terms as $term) {
             if (!$term->getPopularity()) {
                 continue;
             }
             $term->setRatio(($term->getPopularity() - $this->_minPopularity) / $range);
             $temp[$term->getName()] = $term;
             $termKeys[] = $term->getName();
         }
         natcasesort($termKeys);
         foreach ($termKeys as $termKey) {
             $this->_terms[$termKey] = $temp[$termKey];
         }
     }
     return $this;
 }
コード例 #12
0
 /**
  * Execute the command.
  *
  * @param Input $input
  * @param Output $output
  * @return void
  */
 protected function execute(Input $input, Output $output)
 {
     $name = $input->getArgument("name");
     // Validate the name straight away.
     if (count($chunks = explode("/", $name)) != 2) {
         throw new \InvalidArgumentException("Invalid repository name '{$name}'.");
     }
     $output->writeln(sprintf("Cloning <comment>%s</comment> into <info>%s/%s</info>...", $name, getcwd(), end($chunks)));
     // If we're in a test environment, stop executing.
     if (defined("ADVISER_UNDER_TEST")) {
         return null;
     }
     // @codeCoverageIgnoreStart
     if (!$this->git->cloneGithubRepository($name)) {
         throw new \UnexpectedValueException("Repository https://github.com/{$name} doesn't exist.");
     }
     // Change the working directory.
     chdir($path = getcwd() . "/" . end($chunks));
     $output->writeln(sprintf("Changed the current working directory to <comment>%s</comment>.", $path));
     $output->writeln("");
     // Running "AnalyseCommand"...
     $arrayInput = [""];
     if (!is_null($input->getOption("formatter"))) {
         $arrayInput["--formatter"] = $input->getOption("formatter");
     }
     $this->getApplication()->find("analyse")->run(new ArrayInput($arrayInput), $output);
     // Change back, remove the directory.
     chdir(getcwd() . "/..");
     $this->removeDirectory($path);
     $output->writeln("");
     $output->writeln(sprintf("Switching back to <info>%s</info>, removing <comment>%s</comment>...", getcwd(), $path));
     // @codeCoverageIgnoreStop
 }
コード例 #13
0
 function getInvoiceItems($id)
 {
     $sql = "SELECT * FROM " . TB_PREFIX . "invoice_items WHERE invoice_id = :id";
     $sth = dbQuery($sql, ':id', $id);
     $invoiceItems = null;
     for ($i = 0; $invoiceItem = $sth->fetch(); $i++) {
         $invoiceItem['quantity'] = $invoiceItem['quantity'];
         $invoiceItem['unit_price'] = $invoiceItem['unit_price'];
         $invoiceItem['tax_amount'] = $invoiceItem['tax_amount'];
         $invoiceItem['gross_total'] = $invoiceItem['gross_total'];
         $invoiceItem['total'] = $invoiceItem['total'];
         $sql = "SELECT * FROM " . TB_PREFIX . "products WHERE id = :id";
         $tth = dbQuery($sql, ':id', $invoiceItem['product_id']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['product'] = $tth->fetch();
         $attr_sql = "select \r\n                    CONCAT(a.display_name, '-',v.value) as display,\r\n\t\t\t\t\tCONCAT(p.id, '-', a.id, '-', v.id) as id, \r\n\t\t\t\t\ta.id as aid \r\n                from\r\n                    si_products_attributes a,\r\n                    si_products_values v,\r\n\t\t\t\t\tsi_products_matrix m,\r\n\t\t\t\t\tsi_products p\r\n                where\r\n\t\t\t\t\tp.id = m.product_id \r\n\t\t\t\t\tand \r\n\t\t\t\t\ta.id = m.attribute_id \r\n\t\t\t\t\tand \r\n                    a.id = v.attribute_id\r\n\t\t\t\t\tand\r\n\t\t\t\t\tp.id = :pid\r\n                    and\r\n                    v.id = :attr_id";
         $attr_all_sql = "select \r\n                    CONCAT(a.display_name, '-',v.value) as display,\r\n\t\t\t\t\tCONCAT(p.id, '-', a.id, '-', v.id) as id \r\n\t\t\t\t\r\n                from\r\n                    si_products_attributes a,\r\n                    si_products_values v,\r\n\t\t\t\t\tsi_products_matrix m,\r\n\t\t\t\t\tsi_products p\r\n                where\r\n\t\t\t\t\tp.id = m.product_id \r\n\t\t\t\t\tand \r\n\t\t\t\t\ta.id = m.attribute_id \r\n\t\t\t\t\tand \r\n                    a.id = v.attribute_id\r\n\t\t\t\t\tand\r\n\t\t\t\t\tp.id = :pid\r\n                    and\r\n                    m.attribute_id = :aid\r\n                    and\r\n                    v.id != :attr_id";
         $attr1 = dbQuery($attr_sql, ':attr_id', $invoiceItem['attribute_1'], ':pid', $invoiceItem['product_id']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr1'] = $attr1->fetch();
         $attr_all_1 = dbQuery($attr_all_sql, ':attr_id', $invoiceItem['attribute_1'], ':pid', $invoiceItem['product_id'], ':aid', $invoiceItem['attr1']['aid']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr_all_1'] = $attr_all_1->fetchAll();
         $attr2 = dbQuery($attr_sql, ':attr_id', $invoiceItem['attribute_2'], ':pid', $invoiceItem['product_id']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr2'] = $attr2->fetch();
         $attr_all_2 = dbQuery($attr_all_sql, ':attr_id', $invoiceItem['attribute_2'], ':pid', $invoiceItem['product_id'], ':aid', $invoiceItem['attr2']['aid']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr_all_2'] = $attr_all_2->fetchAll();
         $attr3 = dbQuery($attr_sql, ':attr_id', $invoiceItem['attribute_3'], ':pid', $invoiceItem['product_id']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr3'] = $attr3->fetch();
         $attr_all_3 = dbQuery($attr_all_sql, ':attr_id', $invoiceItem['attribute_3'], ':pid', $invoiceItem['product_id'], ':aid', $invoiceItem['attr2']['aid']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr_all_3'] = $attr_all_3->fetchAll();
         $invoiceItems[$i] = $invoiceItem;
     }
     return $invoiceItems;
 }
コード例 #14
0
ファイル: floatToIEEE32.php プロジェクト: echosoar/phpBinary
function main($num)
{
    if ($num < 0) {
        $s = 1;
        $num = -$num;
    } else {
        $s = 0;
    }
    $zs = floor($num);
    $bzs = decbin($zs);
    $xs = $num - $zs;
    $res = (double) ($bzs . '.' . tenToBinary($xs, 1));
    $teme = ws($res);
    $e = decbin($teme + 127);
    if ($teme == 0) {
        $e = '0' . $e;
    }
    $temm = $res / pow(10, $teme);
    $m = end(explode(".", $temm));
    $lenm = strlen($m);
    if ($lenm < 23) {
        $m .= addzero(23 - $lenm);
    }
    return $s . ' ' . $e . ' ' . $m . ' ';
}
コード例 #15
0
 /**
  * Add an item of type BaseField to the field collection
  *
  * @param BaseField $objItem
  */
 public function addItem(BaseField $objItem)
 {
     $this->items[] = $objItem;
     end($this->items);
     $key = key($this->items);
     $this->index[$key] = $objItem->get('colName');
 }
コード例 #16
0
 public function getPropertyProtein()
 {
     $lines = explode("\n", $this->sequence);
     if (isset($lines[0]) && substr($lines[0], 0, 1) == '>') {
         array_shift($lines);
     }
     if (!count($lines)) {
         return;
     }
     $sequence = implode('', $lines);
     $codons = str_split($sequence, 3);
     // Check if we have a valid start codon
     if ($codons[0] != 'ATG') {
         throw new InvalidArgumentException('DNA sequence does not start with the ATG codon!');
     }
     // Check if we have a valid stop codon
     if (!in_array(end($codons), array('TAG', 'TAA', 'TGA'))) {
         throw new InvalidArgumentException('DNA sequence does not end with a valid stop codon! (TAG, TAA or TGA)');
     }
     $model = $this->getObject('com://stevenrombauts/genes.model.aminoacids');
     $protein = '';
     reset($codons);
     foreach ($codons as $codon) {
         $protein .= $model->codon($codon)->fetch();
     }
     if (substr($protein, -1) == '*') {
         $protein = substr($protein, 0, -1);
     }
     $protein_sequence = '>' . $this->title . '_protein' . PHP_EOL . $protein;
     return $protein_sequence;
 }
コード例 #17
0
ファイル: ldap.class.php プロジェクト: guillaum3f/codie
 private function get_last_uid()
 {
     $result = $this->get_all_members();
     $last_entry = end($result);
     $last_uid = isset($last_entry['uid'][0]) ? $last_entry['uid'][0] : 1;
     return $last_uid;
 }
コード例 #18
0
 /**
  * @param KalturaMetadataFilter $filter
  * @param $shouldUpdate
  * @return int
  */
 protected function indexMetadataObjects(KalturaMetadataFilter $filter, $shouldUpdate)
 {
     $filter->orderBy = KalturaMetadataOrderBy::CREATED_AT_ASC;
     $metadataPlugin = KalturaMetadataClientPlugin::get(KBatchBase::$kClient);
     $metadataList = $metadataPlugin->metadata->listAction($filter, $this->pager);
     if (!count($metadataList->objects)) {
         return 0;
     }
     KBatchBase::$kClient->startMultiRequest();
     foreach ($metadataList->objects as $metadata) {
         $metadataPlugin->metadata->index($metadata->id, $shouldUpdate);
     }
     $results = KBatchBase::$kClient->doMultiRequest();
     foreach ($results as $index => $result) {
         if (!is_int($result)) {
             unset($results[$index]);
         }
     }
     if (!count($results)) {
         return 0;
     }
     $lastIndexId = end($results);
     $this->setLastIndexId($lastIndexId);
     return count($results);
 }
コード例 #19
0
 /**
  * Check if (current) user has access to the participant list
  * @param type $a_obj
  * @param type $a_usr_id
  */
 public static function hasParticipantListAccess($a_obj_id, $a_usr_id = null)
 {
     if (!$a_usr_id) {
         $a_usr_id = $GLOBALS['ilUser']->getId();
     }
     // if write access granted => return true
     $refs = ilObject::_getAllReferences($a_obj_id);
     $ref_id = end($refs);
     if ($GLOBALS['ilAccess']->checkAccess('write', '', $ref_id)) {
         return true;
     }
     $part = self::getInstanceByObjId($a_obj_id);
     if ($part->isAssigned($a_usr_id)) {
         if ($part->getType() == 'crs') {
             // Check for show_members
             include_once './Modules/Course/classes/class.ilObjCourse.php';
             if (!ilObjCourse::lookupShowMembersEnabled($a_obj_id)) {
                 return false;
             }
         }
         return true;
     }
     // User is not assigned to course/group => no read access
     return false;
 }
コード例 #20
0
ファイル: selector.class.php プロジェクト: bagi091/Selector
 /**
  * @param $list
  * @param array $ph
  * @return string
  */
 public function renderJS($list, $ph = array())
 {
     $js = '';
     $scripts = MODX_BASE_PATH . $list;
     if ($this->fs->checkFile($scripts)) {
         $scripts = @file_get_contents($scripts);
         $scripts = $this->DLTemplate->parseChunk('@CODE:' . $scripts, $ph);
         $scripts = json_decode($scripts, true);
         $scripts = isset($scripts['scripts']) ? $scripts['scripts'] : $scripts['styles'];
         foreach ($scripts as $name => $params) {
             if (!isset($this->modx->loadedjscripts[$name])) {
                 if ($this->fs->checkFile($params['src'])) {
                     $this->modx->loadedjscripts[$name] = array('version' => $params['version']);
                     if (end(explode('.', $params['src'])) == 'js') {
                         $js .= '<script type="text/javascript" src="' . $this->modx->config['site_url'] . $params['src'] . '"></script>';
                     } else {
                         $js .= '<link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . $params['src'] . '">';
                     }
                 } else {
                     $this->modx->logEvent(0, 3, 'Cannot load ' . $params['src'], $this->customTvName);
                 }
             }
         }
     } else {
         if ($list == $this->jsListDefault) {
             $this->modx->logEvent(0, 3, "Cannot load {$this->jsListDefault} .", $this->customTvName);
         } elseif ($list == $this->cssListDefault) {
             $this->modx->logEvent(0, 3, "Cannot load {$this->cssListDefault} .", $this->customTvName);
         }
     }
     return $js;
 }
コード例 #21
0
 public function __construct($method, $find, $delimiter = '::')
 {
     $expl = explode($delimiter, $method);
     if (end($expl) !== $find) {
         throw new InvalidArgumentException(sprintf("The method not was found, instead: \"%s\"", $method));
     }
 }
コード例 #22
0
ファイル: Day07.php プロジェクト: jklance/adventcode
 public function processOperations($operations = NULL)
 {
     $this->_wires = array();
     $return = NULL;
     if ($operations) {
         $this->_queue = explode('::', $operations);
         $changed = true;
         // Repeat so long as there are items in the queue AND we made a change last pass
         // (if we didn't, we're stalled, let's bail on this)
         while ($changed && count($this->_queue > 0)) {
             asort($this->_queue);
             $changed = false;
             foreach ($this->_queue as $k => $operation) {
                 $returnSub = explode(" ", $operation);
                 $returnSub = end($returnSub);
                 $return = $this->processOperation($operation, $returnSub);
                 if ($return) {
                     $changed = true;
                     unset($this->_queue[$k]);
                 }
             }
             echo "\n a: " . $this->_wires['a'] . "\n";
         }
     }
     return $return;
 }
コード例 #23
0
 /**
  * @param string $resourceClassName Fully classified class name
  *
  * @return string
  */
 protected function getClassNameOnly($resourceClassName = null)
 {
     $name = null === $resourceClassName ? static::class : $resourceClassName;
     $name = explode('\\', $name);
     $name = end($name);
     return $name;
 }
コード例 #24
0
ファイル: class_attachment.php プロジェクト: name256/crm42
 function getRandomName($filename)
 {
     $file_array = explode(".", $filename);
     $file_ext = end($file_array);
     $new_file_name = uniqid() . date('m') . date('d') . date('Y') . date('G') . date('i') . date('s') . "." . $file_ext;
     return $new_file_name;
 }
コード例 #25
0
ファイル: comments.php プロジェクト: karimo255/blog
 private function buildForm()
 {
     $this->load->lib('form');
     $tags = array();
     $legend = "Leave a comment";
     $options = array('id' => 'comment-form', 'class' => 'form', 'name' => 'comment_form', 'jsValidateFunction' => 'validateComment', 'novalidate' => NULL, 'validateElements' => array('input', 'textarea'));
     $this->lib_form->open($legend, $options);
     //title
     if (isset($this->request->post['name'])) {
         $name_v = $this->request->post['name'];
     } else {
         $name_v = '';
     }
     //for page titel
     $this->lib_form->hidden('post_titel', end(explode('/', $this->request->get['url'])));
     $this->lib_form->label('Name');
     $this->lib_form->text('name', $name_v, ['data-validation-required-message' => 'Please enter a Name', 'id' => 'name', 'required' => '', 'error' => $this->error['vorname']]);
     $this->lib_form->label('Email');
     $this->lib_form->email('email', $email_v, ['data-validation-required-message' => 'Please enter a Email', 'required' => '', 'error' => $this->error['email']]);
     $this->lib_form->captcha('captcha', ['refresh_btn' => true]);
     $this->lib_form->label('Captcha Code');
     $this->lib_form->text('captcha_check', $captcha_v, ['data-validation-required-message' => 'Please enter the Captcha Code', 'required' => '', 'minlength' => 5, 'data-validation-minlength-message' => 'Min Length is 5 Charachter', 'error' => $this->error['captcha']]);
     $this->lib_form->label('Comment');
     $this->lib_form->textarea('body', $body_v, ['maxlength' => 500, 'data-validation-required-message' => 'Please enter a Comment', 'required' => '', 'error' => $this->error['body'], 'rows' => '3']);
     $this->lib_form->button('submit', 'primary', $options = array('type' => 'submit'));
     return $this->lib_form;
 }
コード例 #26
0
ファイル: transaction.class.php プロジェクト: liuyu121/myqee
 /**
  * 提交事务,支持子事务
  *
  * @return Boolean true:成功
  * @throws Exception
  */
 public function commit()
 {
     if (!$this->id || !$this->_haveid()) {
         return false;
     }
     if ($this->is_root()) {
         # 父事务
         while (count(Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id]) > 1) {
             # 还有没有提交的子事务
             end(Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id]);
             $subid = key(Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id]);
             if (!$this->_release_save_point($subid)) {
                 throw new Exception('commit error');
             }
         }
         $status = $this->_query('COMMIT;');
         $this->_query('SET AUTOCOMMIT=1;');
         if ($status) {
             unset(Database_Driver_MySQLI_Transaction::$transactions[$this->_connection_id]);
         }
     } else {
         # 子事务
         $status = $this->_release_save_point($this->id);
     }
     if ($status) {
         $this->id = null;
         return true;
     } else {
         throw new Exception('not commit transaction');
     }
 }
コード例 #27
0
ファイル: header_top.php プロジェクト: Vitronic/kaufreund.de
 public function index()
 {
     $this->load->model('design/layout');
     $this->load->model('catalog/category');
     $this->load->model('catalog/product');
     $this->load->model('catalog/information');
     if (isset($this->request->get['route'])) {
         $route = (string) $this->request->get['route'];
     } else {
         $route = 'common/home';
     }
     $layout_id = 0;
     if ($route == 'product/category' && isset($this->request->get['path'])) {
         $path = explode('_', (string) $this->request->get['path']);
         $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));
     }
     if ($route == 'product/product' && isset($this->request->get['product_id'])) {
         $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
     }
     if ($route == 'information/information' && isset($this->request->get['information_id'])) {
         $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
     }
     if (!$layout_id) {
         $layout_id = $this->model_design_layout->getLayout($route);
     }
     if (!$layout_id) {
         $layout_id = $this->config->get('config_layout_id');
     }
     $module_data = array();
     $this->load->model('setting/extension');
     $extensions = $this->model_setting_extension->getExtensions('module');
     foreach ($extensions as $extension) {
         $modules = $this->config->get($extension['code'] . '_module');
         if ($modules) {
             foreach ($modules as $module) {
                 if ($module['layout_id'] == $layout_id && $module['position'] == 'header_top' && $module['status']) {
                     $module_data[] = array('code' => $extension['code'], 'setting' => $module, 'sort_order' => $module['sort_order']);
                 }
             }
         }
     }
     $sort_order = array();
     foreach ($module_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $module_data);
     $this->data['modules'] = array();
     foreach ($module_data as $module) {
         $module = $this->getChild('module/' . $module['code'], $module['setting']);
         if ($module) {
             $this->data['modules'][] = $module;
         }
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_top.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/common/header_top.tpl';
     } else {
         $this->template = 'default/template/common/header_top.tpl';
     }
     $this->render();
 }
コード例 #28
0
ファイル: css.php プロジェクト: noccy80/lepton-ng
 public function refactor(RefactorFileset $fileset) {
     $tofunc = reset(explode('(',$this->to));
     $toargs = reset(explode(')',end(explode('(',$this->to))));
     $mod = array();
     foreach($fileset->files as $file) {
         if (file_exists($file.'.rf')) {
             $in = file_get_contents($file.'.rf');
         } else {
             $in = file_get_contents($file);
         }
         foreach($this->from as $from) {
             $func = reset(explode('(',$from));
             $args = reset(explode(')',end(explode('(',$from))));
             if ($args == $toargs) {
                 // Just change function names
                 $ref = str_replace($func.'(',$tofunc.'(',$in);
             }
         }
         if ($ref != $in) {
             $mod[] = $file;
             file_put_contents($file.'.rf', $ref);
         }
     }
     return $mod;
 }
コード例 #29
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->view->assign('heading_title', $this->language->get('heading_title'));
     $this->loadModel('catalog/category');
     if (isset($this->request->get['path'])) {
         $this->path = explode('_', $this->request->get['path']);
         $this->category_id = end($this->path);
     }
     $this->view->assign('selected_category_id', $this->category_id);
     $this->view->assign('path', $this->request->get['path']);
     //load main lavel categories
     $all_categories = $this->model_catalog_category->getAllCategories();
     $this->view->assign('category_list', $this->_buildCategoryTree($all_categories));
     // framed needs to show frames for generic block.
     //If tpl used by listing block framed was set by listing block settings
     $this->view->assign('block_framed', true);
     //Load nested categories and with all details based on whole categories list array in $this->data
     $this->data['resource_obj'] = new AResource('image');
     $this->view->assign('home_href', $this->html->getSEOURL('index/home'));
     $this->view->assign('categories', $this->_buildNestedCategoryList());
     $this->processTemplate();
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
コード例 #30
0
ファイル: shortcodes.php プロジェクト: slavai/sadick
function tt_event_hours($atts, $content)
{
    extract(shortcode_atts(array("title" => "Event Hours", "time_format" => "H.i", "class" => "", "hour_category" => "", "text_color" => "", "border_color" => "", "columns" => ""), $atts));
    if ($hour_category != null && $hour_category != "-") {
        $hour_category = array_values(array_diff(array_filter(array_map('trim', explode(",", $hour_category))), array("-")));
    }
    if ($columns != "") {
        $weekdays_explode = explode(",", $columns);
        $weekdays_in_query = "";
        foreach ($weekdays_explode as $weekday_explode) {
            $weekdays_in_query .= "'" . $weekday_explode . "'" . ($weekday_explode != end($weekdays_explode) ? "," : "");
        }
    }
    global $wpdb;
    global $post;
    //The actual fields for data entry
    $query = "SELECT * FROM `" . $wpdb->prefix . "event_hours` AS t1 LEFT JOIN {$wpdb->posts} AS t2 ON t1.weekday_id=t2.ID \r\n\t\tWHERE t1.event_id='" . $post->ID . "'";
    if ($hour_category != null && $hour_category != "-") {
        $query .= "\r\n\t\t\tAND t1.category IN('" . join("','", $hour_category) . "')";
    }
    if ($weekdays_in_query != "") {
        $query .= " AND t2.post_name IN(" . $weekdays_in_query . ")";
    }
    $query .= " ORDER BY t2.menu_order, t1.start, t1.end";
    $event_hours = $wpdb->get_results($query);
    $event_hours_count = count($event_hours);
    if ($event_hours_count) {
        //get weekdays
        $query = "SELECT ID, post_title FROM {$wpdb->posts}\r\n\t\t\t\tWHERE \r\n\t\t\t\tpost_type='timetable_weekdays'\r\n\t\t\t\tORDER BY menu_order";
        $weekdays = $wpdb->get_results($query);
        $output = '';
        if ($title != "") {
            $output .= '<h3 class="tt_event_margin_top_27">' . $title . '<span class="tt_event_hours_count">(' . $event_hours_count . ')</span></h3>';
        }
        $output .= '
		<ul id="event_hours_list" class="timetable_clearfix tt_event_hours' . ($class != "" ? ' ' . $class : '') . '">';
        for ($i = 0; $i < $event_hours_count; $i++) {
            //get event color
            if ($border_color == "") {
                $border_color = "#" . get_post_meta($event_hours[$i]->event_id, "timetable_color", true);
            }
            //get day by id
            $current_day = get_post($event_hours[$i]->weekday_id);
            $output .= '<li' . ($border_color != "" ? ' style="border-left-color:' . $border_color . ';"' : '') . ' id="event_hours_' . $event_hours[$i]->event_hours_id . '" class="event_hours_' . ($i % 2 == 0 ? 'left' : 'right') . '"><h4' . ($text_color != "" ? ' style="color:' . $text_color . ';"' : '') . '>' . $current_day->post_title . '</h4><h4' . ($text_color != "" ? ' style="color:' . $text_color . ';"' : '') . '>' . date($time_format, strtotime($event_hours[$i]->start)) . ' - ' . date($time_format, strtotime($event_hours[$i]->end)) . '</h4>';
            if ($event_hours[$i]->before_hour_text != "" || $event_hours[$i]->after_hour_text != "") {
                $output .= '<p' . ($text_color != "" ? ' style="color:' . $text_color . ';"' : '') . ' class="tt_event_padding_bottom_0">';
                if ($event_hours[$i]->before_hour_text != "") {
                    $output .= $event_hours[$i]->before_hour_text;
                }
                if ($event_hours[$i]->after_hour_text != "") {
                    $output .= ($event_hours[$i]->before_hour_text != "" ? '<br>' : '') . $event_hours[$i]->after_hour_text;
                }
                $output .= '</p>';
            }
            $output .= '</li>';
        }
        $output .= '</ul>';
    }
    return $output;
}