コード例 #1
0
ファイル: SegmentTest.php プロジェクト: sidis405/area.dev
 /**
  * @test
  */
 public function it_is_chainable()
 {
     $this->assertInstanceOf(\Spatie\String\Str::class, string('foo/bar/baz')->segment('/', 0));
     $this->assertInstanceOf(\Spatie\String\Str::class, string('foo/bar/baz')->firstSegment('/'));
     $this->assertInstanceOf(\Spatie\String\Str::class, string('foo/bar/baz')->lastSegment('/'));
     $this->assertInstanceOf(\Spatie\String\Str::class, string('foo/bar/baz')->pop('/'));
 }
コード例 #2
0
function mysql_to_json($connection_name, $table_name, $file_name)
{
    // Verifies that table name and connection to MySQL exist.
    if (!$connection_name || !$table_name) {
        return false;
    }
    // If the user did not enter a desired file name, a unique one will be initiated.
    if (!$file_name) {
        $file_name = "new_json_file" . idate("U");
    }
    // Type casts input variables to strings in the case that the user entered a different variable type.
    $table_name = string($table_name);
    $file_name = string($file_name);
    // Query data from MySQL server.
    $data_query = "SELECT * FROM {$table_name}";
    $data_request = @mysqli_query($connection_name, $data_query);
    // Insert queried data into an array.
    $data_saved[] = array();
    while ($entry = mysqli_fetch_assoc($data_request)) {
        $data_saved[] = $entry;
    }
    // Copy array data to file.
    $file_wrtie = fopen($file_name, 'w');
    fwrite($file_write, json_encode($data_saved));
    fclose($file_write);
    // Return true to let the user know that everything ran successfully.
    return true;
}
コード例 #3
0
ファイル: UserSeeder.php プロジェクト: bjrnblm/blender
 protected function seedAdmins()
 {
     $users = ['Willem' => 'Van Bockstal', 'Freek' => 'Van der Herten', 'Rogier' => 'De Boevé', 'Sebastian' => 'De Deyne'];
     foreach ($users as $firstName => $lastName) {
         factory(User::class)->create(['email' => strtolower($firstName) . '@spatie.be', 'password' => app()->env == 'local' ? strtolower($firstName) : string()->random(), 'first_name' => $firstName, 'last_name' => $lastName, 'role' => UserRole::ADMIN, 'status' => UserStatus::ACTIVE]);
     }
 }
コード例 #4
0
 public function seedAdmins()
 {
     $users = ['Willem' => 'Van Bockstal', 'Freek' => 'Van der Herten', 'Rogier' => 'De Boevé', 'Sebastian' => 'De Deyne'];
     collect($users)->each(function ($lastName, $firstName) {
         $password = app()->environment('local') ? strtolower($firstName) : string()->random();
         User::create(['email' => strtolower($firstName) . '@spatie.be', 'password' => bcrypt($password), 'first_name' => $firstName, 'last_name' => $lastName, 'role' => UserRole::ADMIN(), 'status' => UserStatus::ACTIVE()]);
     });
 }
コード例 #5
0
ファイル: helpers.php プロジェクト: vanslambrouckd/blender
/**
 * Get a translated fragment's text. Since this utility function is occasionally used in route files, there's also a
 * check for the database connection to return a fallback fragment in local environments.
 *
 * @param string $locale
 *
 * @return \Spatie\String\Str | string
 */
function fragment(string $name, $locale = null)
{
    $locale = $locale ?: content_locale();
    $fragment = App\Models\Fragment::findByName($name);
    if (!$fragment) {
        return $name;
    }
    return string($fragment->getTranslation($locale)->text);
}
コード例 #6
0
 /**
  * Perform the conversion.
  *
  * @param \Spatie\MediaLibrary\Media $media
  * @param Conversion $conversion
  * @param string $copiedOriginalFile
  *
  * @return string
  */
 public function performConversion(Media $media, Conversion $conversion, string $copiedOriginalFile)
 {
     $conversionTempFile = pathinfo($copiedOriginalFile, PATHINFO_DIRNAME) . '/' . string()->random(16) . $conversion->getName() . '.' . $media->extension;
     File::copy($copiedOriginalFile, $conversionTempFile);
     foreach ($conversion->getManipulations() as $manipulation) {
         GlideImage::create($conversionTempFile)->modify($manipulation)->save($conversionTempFile);
     }
     return $conversionTempFile;
 }
コード例 #7
0
ファイル: menuBuilding.php プロジェクト: LucasBullen/engLinks
function my_plugin_menu()
{
    $user = string(wp_get_current_user());
    echo $user;
    if (in_array("author", (array) $user->roles)) {
        echo '';
    }
    add_dashboard_page('Tutors', 'Tutors', 'read', 'myuniqueidentifier', 'my_plugin_options');
    add_dashboard_page('View Students', 'Students', 'read', 'myuniqueidentifier1', 'ctc_students');
}
コード例 #8
0
 /**
  * Get body and/or body segments
  * 
  * @param  bool|string $spec 
  * @return string|array|null
  */
 public function getBody($spec = false)
 {
     if (false === $spec) {
         return $this->outputBody();
     } elseif (true === $spec) {
         return $this->_body;
     } elseif (is - string($spec) && isset($this->_body[$spec])) {
         return $this->_body[$spec];
     }
     return null;
 }
コード例 #9
0
ファイル: Pattern.php プロジェクト: lastguest/yay
 private function compile(array $tokens)
 {
     $cg = (object) ['ts' => TokenStream::fromSlice($tokens), 'parsers' => []];
     traverse(rtoken('/^(T_\\w+)·(\\w+)$/')->onCommit(function (Ast $result) use($cg) {
         $token = $result->token();
         $id = $this->lookupCapture($token);
         $type = $this->lookupTokenType($token);
         $cg->parsers[] = token($type)->as($id);
     }), ($parser = chain(rtoken('/^·\\w+$/')->as('type'), token('('), optional(ls(either(future($parser)->as('parser'), chain(token(T_FUNCTION), parentheses()->as('args'), braces()->as('body'))->as('function'), string()->as('string'), rtoken('/^T_\\w+·\\w+$/')->as('token'), rtoken('/^T_\\w+$/')->as('constant'), rtoken('/^·this$/')->as('this'), label()->as('label'))->as('parser'), token(',')))->as('args'), commit(token(')')), optional(rtoken('/^·\\w+$/')->as('label'), null)))->onCommit(function (Ast $result) use($cg) {
         $cg->parsers[] = $this->compileParser($result->type, $result->args, $result->label);
     }), $this->layer('{', '}', braces(), $cg), $this->layer('[', ']', brackets(), $cg), $this->layer('(', ')', parentheses(), $cg), rtoken('/^···(\\w+)$/')->onCommit(function (Ast $result) use($cg) {
         $id = $this->lookupCapture($result->token());
         $cg->parsers[] = layer()->as($id);
     }), token(T_STRING, '·')->onCommit(function (Ast $result) use($cg) {
         $offset = \count($cg->parsers);
         if (0 !== $this->dominance || 0 === $offset) {
             $this->fail(self::E_BAD_DOMINANCE, $offset, $result->token()->line());
         }
         $this->dominance = $offset;
     }), rtoken('/·/')->onCommit(function (Ast $result) {
         $token = $result->token();
         $this->fail(self::E_BAD_CAPTURE, $token, $token->line());
     }), any()->onCommit(function (Ast $result) use($cg) {
         $cg->parsers[] = token($result->token());
     }))->parse($cg->ts);
     // check if macro dominance '·' is last token
     if ($this->dominance === \count($cg->parsers)) {
         $this->fail(self::E_BAD_DOMINANCE, $this->dominance, $cg->ts->last()->line());
     }
     $this->specificity = \count($cg->parsers);
     if ($this->specificity > 1) {
         if (0 === $this->dominance) {
             $pattern = chain(...$cg->parsers);
         } else {
             /*
               dominat macros are partially wrapped in commit()s and dominance
               is the offset used as the 'event horizon' point... once the entry
               point is matched, there is no way back and a parser error arises
             */
             $prefix = array_slice($cg->parsers, 0, $this->dominance);
             $suffix = array_slice($cg->parsers, $this->dominance);
             $pattern = chain(...array_merge($prefix, array_map(commit::class, $suffix)));
         }
     } else {
         /*
           micro optimization to save one function call for every token on the subject
           token stream whenever the macro pattern consists of a single parser
         */
         $pattern = $cg->parsers[0];
     }
     return $pattern;
 }
コード例 #10
0
 private function fillFeed(Feed $feed)
 {
     $posts = app(ContentRepository::class)->posts();
     $feed->title = 'Sebastian De Deyne';
     $feed->description = 'Full-stack developer working at Spatie in Antwerp, Belgium';
     $feed->link = request()->url();
     $feed->setDateFormat('datetime');
     $feed->pubdate = $posts->first() ? $posts->first()->date : Carbon::now();
     $feed->lang = 'en';
     $feed->setShortening(false);
     $posts->each(function (Article $post) use($feed) {
         $feed->add($post->title, 'Sebastian De Deyne', $post->url, $post->date, string($post->contents)->tease(140), $post->contents);
     });
 }
コード例 #11
0
 /**
  * @param \App\Http\Requests\Front\NewsletterSubscriptionRequest $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function subscribe(NewsletterSubscriptionRequest $request)
 {
     try {
         $this->newsletter->subscribe($request->get('email'));
         Activity::log($request->get('email') . ' schreef zich in op de nieuwsbrief.');
     } catch (AlreadySubscribed $exception) {
         return $this->respond(string('newsletter.subscription.result.alreadySubscribed'));
     } catch (ServiceRefusedSubscription $exception) {
         return $this->respondWithBadRequest(string('newsletter.subscription.result.error'));
     } catch (Exception $e) {
         Log::error('newsletter subscription failed with exception message: ' . $e->getMessage());
         return $this->respondWithInternalServerError(string('newsletter.subscription.result.error'));
     }
     return $this->respond(string('newsletter.subscription.result.ok'));
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('products', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('reference');
         $table - mediumText('description');
         $table - string('inspection_points');
         $table - string('inspection');
         $table - string('classification');
         $table - string('existence');
         $table - string('enable', 5);
         $table->timestamps();
         $table->softDeletes();
     });
 }
コード例 #13
0
 public function isValid($value, Constraint $constraint)
 {
     if (parent::isValid($value, $constraint)) {
         if ($value instanceof \DateTime) {
             $tm = $value->getTimestamp();
         } else {
             preg_match(self::PATTERN_BIRTHDAY, string($value), $matches);
             $tm = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
         }
         if (time() > $tm) {
             return true;
         }
         $this->setMessage($constraint->messageBirthday, array('{{ value }}' => $value));
     }
     return false;
 }
コード例 #14
0
ファイル: DbDAO.php プロジェクト: BackupTheBerlios/agileweb
 /**
  * DB select query.
  *
  * @param   string|array    $cond
  * @param   string          $order
  * @param   integer         $count
  * @param   integer         $offset
  * @param   string|array    $cols
  * @return  array
  */
 protected function _select($cond = null, $order = null, $count = null, $offset = null, $cols = null)
 {
     $select = $this->_db->select();
     if (empty($cols)) {
         $cols = '*';
     }
     $select->from($this->_table, $cols);
     if ($cond) {
         if (is_array($cond)) {
             foreach ($cond as $field => $value) {
                 $select->where("{$field} = ?", $value);
             }
         } else {
             $select->where(string($cond));
         }
     }
     //end if
     $select->order($order);
     $select->limit($count, $offset);
     return $this->_db->fetchAll($select);
 }
コード例 #15
0
 public function addPostAction(Request $request, Response $response)
 {
     if ($request->isPost()) {
         $data = $request->getParsedBody();
         $title = $data['post_title'];
         $slug = trim($title);
         $slug = str_replace(' ', '-', $slug);
         $alias = $data['post_alias'];
         $content = $data['post_data'];
         $id = string($data['cat']);
         $post = new Posts();
         $post->setAlias($alias);
         $post->setCategory($id);
         $post->setPublished(true);
         $post->setSlug($slug);
         $post->setContent($content);
         $this->em->persist($post);
         $this->em->flush();
     }
     $this->view->render($response, 'admin/post/newpost.html', ['post' => $post]);
     return $response;
 }
コード例 #16
0
ファイル: index.php プロジェクト: rayrc/ajax-seo
$description = null;
$result = false;
if ($conn) {
    $title = $title_error = 'Whoops...';
    $pagetitle = $pagetitle_error = 'Page not found';
    // Old Webkit breaks the layout without </p>
    $content = $content_error = '<p>This page hasn\'t been found. Try to <a class=x-error href=' . $url . '>reload</a>' . ($ishome ? null : ' or head to <a href=' . $path . '>home page</a>') . '.</p>';
    $stmt = $mysqli->prepare('SELECT title, description, content, GREATEST(modified, created) AS date FROM `' . table . '` WHERE url=? LIMIT 1');
    $stmt->bind_param('s', $urldb);
    $stmt->execute();
    $stmt->bind_result($title, $description, $content, $date);
    while ($stmt->fetch()) {
        $result = true;
        // SEO page title improvement for the root page
        $pagetitle = $ishome ? $title : $gtitle;
        $content = string($content);
    }
    $stmt->free_result();
    $stmt->close();
    if (!$result) {
        // URL does not exist
        http_response_code(404);
        $title = $title_error;
        $content = $content_error;
        $pagetitle = $pagetitle_error;
    }
    if (isset($_GET['api'])) {
        // API
        include 'content/api.php';
        exit;
    }
コード例 #17
0
ファイル: MogileFS.php プロジェクト: rshariffdeen/olio
 function create($key, $replication_factor = 2, $overwrite = 'true')
 {
     $this->saveFile($key, string($replication_factor), $key);
 }
コード例 #18
0
ファイル: ArticlePresenter.php プロジェクト: bjrnblm/blender
 /**
  * @param string $characters
  * @param string $moreTextIndicator
  *
  * @return \Spatie\String\Str
  */
 public function tease($characters, $moreTextIndicator = '...')
 {
     return (string) string($this->entity->text)->tease($characters, $moreTextIndicator);
 }
コード例 #19
0
ファイル: NewsItemPresenter.php プロジェクト: bjrnblm/blender
 /**
  *  Get an array with all possible types.
  *
  * @param int $length
  *
  * @return \Spatie\String\Str
  */
 public function excerpt($length = 200)
 {
     return string($this->entity->text)->tease($length);
 }
コード例 #20
0
function count_attributes($dir, $single_file = FALSE)
{
    $no_activity_dates = array();
    $activities_with_at_least_one = array();
    $no_activities = array();
    $found_hierarchies = array();
    $activities_with_attribute = array();
    $activity_by = array();
    $document_links = array();
    $result_element = array();
    $conditions = array();
    $participating_org_accountable = array();
    $participating_org_implementing = array();
    $budget = array();
    $identifiers = array();
    $transaction_type_commitment = array();
    $transaction_type_disbursement = array();
    $transaction_type_expenditure = array();
    $no_disbursements = $no_incoming_funds = $no_tracable_transactions = array();
    $activities_with_sector = array();
    $most_recent = array();
    $activities_with_location = array();
    $activities_with_coordinates = array();
    $activities_with_adminstrative = array();
    $activities_sector_assumed_dac = array();
    $activities_sector_declared_dac = array();
    $activies_in_country_lang = array();
    $i = 0;
    //used to count bad id's
    if ($handle = opendir($dir)) {
        //echo "Directory handle: $handle\n";
        //echo "Files:\n";
        /* This is the correct way to loop over the directory. */
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                //ignore these system files
                //echo $file . PHP_EOL;
                if ($single_file && $file != $single_file) {
                    //skip all files except the one we want if set/requested.Handy to test just one file in a directory
                    continue;
                }
                //load the xml SAFELY
                /* Some safety against XML Injection attack
                 * see: http://phpsecurity.readthedocs.org/en/latest/Injection-Attacks.html
                 * 
                 * Attempt a quickie detection of DOCTYPE - discard if it is present (cos it shouldn't be!)
                 */
                $xml = file_get_contents($dir . $file);
                $collapsedXML = preg_replace("/[[:space:]]/", '', $xml);
                //echo $collapsedXML;
                if (preg_match("/<!DOCTYPE/i", $collapsedXML)) {
                    //throw new InvalidArgumentException(
                    //     'Invalid XML: Detected use of illegal DOCTYPE'
                    // );
                    //echo "fail";
                    return FALSE;
                }
                $loadEntities = libxml_disable_entity_loader(true);
                $dom = new DOMDocument();
                $dom->loadXML($xml);
                foreach ($dom->childNodes as $child) {
                    if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
                        throw new Exception\ValueException('Invalid XML: Detected use of illegal DOCTYPE');
                        libxml_disable_entity_loader($loadEntities);
                        return FALSE;
                    }
                }
                libxml_disable_entity_loader($loadEntities);
                if ($xml = simplexml_import_dom($dom)) {
                    //print_r($xml);
                    if (!xml_child_exists($xml, "//iati-organisation")) {
                        //exclude organisation files
                        $activities = $xml->{"iati-activity"};
                        //print_r($attributes); die;
                        foreach ($activities as $activity) {
                            $hierarchy = (string) $activity->attributes()->hierarchy;
                            if ($hierarchy && $hierarchy != NULL) {
                                $hierarchy = (string) $activity->attributes()->hierarchy;
                            } else {
                                $hierarchy = 0;
                            }
                            $found_hierarchies[] = $hierarchy;
                            if (!isset($no_activities[$hierarchy])) {
                                $no_activities[$hierarchy] = 0;
                            }
                            $no_activities[$hierarchy]++;
                            //Set up some more counters:
                            if (!isset($no_disbursements[$hierarchy])) {
                                $no_disbursements[$hierarchy] = 0;
                            }
                            if (!isset($no_incoming_funds[$hierarchy])) {
                                $no_incoming_funds[$hierarchy] = 0;
                            }
                            if (!isset($no_tracable_transactions[$hierarchy])) {
                                $no_tracable_transactions[$hierarchy] = 0;
                            }
                            //Elements check
                            //is <document-link>,<conditions>,<result> present
                            if (count($activity->{"document-link"}) > 0) {
                                $document_links[$hierarchy][] = (string) $activity->{'iati-identifier'};
                            }
                            if (count($activity->conditions) > 0) {
                                $conditions[$hierarchy][] = (string) $activity->{'iati-identifier'};
                            }
                            if (count($activity->result) > 0) {
                                $result_element[$hierarchy][] = (string) $activity->{'iati-identifier'};
                            }
                            //More elements
                            //Participating Organisation (Implementing)
                            $participating_orgs = $activity->{"participating-org"};
                            foreach ($participating_orgs as $participating_org) {
                                //echo (string)$activity->{"participating-org"}->attributes()->role;
                                if ((string) $participating_org->attributes()->role == "Implementing") {
                                    //echo "yes";
                                    $participating_org_implementing[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                }
                                //Participating Organisation (Accountable)
                                if ((string) $participating_org->attributes()->role == "Accountable") {
                                    $participating_org_accountable[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                }
                            }
                            //Budget/Planned Disbursement
                            if (count($activity->budget) > 0 || count($activity->{"planned-disbursement"}) > 0) {
                                $budget[$hierarchy][] = (string) $activity->{'iati-identifier'};
                            }
                            //Unique Identifier check
                            //Suck up all activity identifiers - check they start with the reporting org string
                            //We count by storing the activity id in an array
                            //if there is no identifier then set a dummy one to dump it into the 'bad' pile
                            if (!isset($activity->{'iati-identifier'})) {
                                $iati_identifier = "noIdentifierGiven" . $i;
                                $i++;
                            } else {
                                $iati_identifier = (string) $activity->{'iati-identifier'};
                            }
                            if (isset($activity->{'reporting-org'}->attributes()->ref)) {
                                $reporting_org_ref = (string) $activity->{'reporting-org'}->attributes()->ref;
                                //echo $reporting_org_ref . PHP_EOL;
                                //echo $iati_identifier . PHP_EOL;
                                if (strpos($reporting_org_ref, $iati_identifier) == 0) {
                                    //echo "yes";
                                    $identifiers[$hierarchy]["good"][] = $iati_identifier;
                                } else {
                                    //echo "no";
                                    $identifiers[$hierarchy]["bad"][] = $iati_identifier;
                                }
                            } else {
                                $identifiers[$hierarchy]["bad"][] = $iati_identifier;
                            }
                            //Financial transaction (Commitment)
                            $transactions = $activity->transaction;
                            //if (count($transactions) == 0) {
                            //  echo $id;
                            //die;
                            //}
                            if (isset($transactions) && count($transactions) > 0) {
                                //something not quite right here
                                //Loop through each of the elements
                                foreach ($transactions as $transaction) {
                                    //print_r($transaction);
                                    //Counts number of elements of this type in this activity
                                    //$no_transactions[$hierarchy]++;
                                    //$transaction_date = (string)$transaction->{'transaction-date'}->attributes()->{'iso-date'};
                                    if (isset($transaction->{'transaction-type'})) {
                                        $transaction_type = (string) $transaction->{'transaction-type'}->attributes()->{'code'};
                                        if ($transaction_type == "C") {
                                            $transaction_type_commitment[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                        }
                                        if ($transaction_type == "D") {
                                            $transaction_type_disbursement[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                            //Count the number of disbursements at this level
                                            $no_disbursements[$hierarchy]++;
                                            //now test it and count the passes
                                            if (isset($transaction->{"receiver-org"})) {
                                                //We have a provider-org = pass!
                                                $no_tracable_transactions[$hierarchy]++;
                                            }
                                            //$no_disbursements = $no_incoming_funds = $no_tracable_transactions = array();
                                        }
                                        if ($transaction_type == "IF") {
                                            //Count the number of IFs at this level
                                            $no_incoming_funds[$hierarchy]++;
                                            if (isset($transaction->{"provider-org"})) {
                                                //We have a provider-org = pass!
                                                $no_tracable_transactions[$hierarchy]++;
                                            }
                                        }
                                        if ($transaction_type == "E") {
                                            $transaction_type_expenditure[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                        }
                                    }
                                    //if code attribute exists
                                }
                            }
                            //Going to need a count of disbursements and of IF transactions
                            //Then need to test each against a set of criteria
                            /*if ($transaction_type == NULL) {
                                $transaction_type = "Missing";
                                echo "missing";
                              }
                              if ($transaction_type !="D") {
                                echo $id;
                                //die;
                              }*/
                            //Locations
                            //We can have more than one location, but they should add up to 100%
                            $locations = $activity->location;
                            //if (!isset($activities_with_location[$hierarchy])) {
                            //  $activities_with_location[$hierarchy] = 0;
                            //}
                            if (isset($locations) && count($locations) > 0) {
                                $activities_with_location[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                foreach ($locations as $location) {
                                    if (isset($location->coordinates)) {
                                        $activities_with_coordinates[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                    }
                                    if (isset($location->administrative)) {
                                        if (isset($location->administrative->attributes()->adm1)) {
                                            $adm1 = string($location->administrative->attributes()->adm1);
                                        }
                                        if (isset($location->administrative->attributes()->adm2)) {
                                            $adm2 = string($location->administrative->attributes()->adm2);
                                        }
                                        if (isset($adm1) && len($adm1) > 0 || isset($adm2) && len($adm2) > 0) {
                                            $activities_with_adminstrative[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                        }
                                    }
                                }
                            }
                            //Sector
                            $sectors = $activity->sector;
                            if (isset($sectors) && count($sectors) > 0) {
                                //$activities_with_sector[$hierarchy][] = (string)$activity->{'iati-identifier'};
                                foreach ($sectors as $sector) {
                                    if (!isset($sector->attributes()->vocabulary)) {
                                        $activities_sector_assumed_dac[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                    } elseif ((string) $sector->attributes()->vocabulary == "DAC") {
                                        //echo "DAC";
                                        $activities_sector_declared_dac[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                    }
                                }
                            }
                            //Last-updated-datetime
                            $last_updated = $activity->attributes()->{'last-updated-datetime'};
                            $last_updated = strtotime($last_updated);
                            if (!isset($most_recent[$hierarchy])) {
                                $most_recent[$hierarchy] = 0;
                            }
                            if ($last_updated > $most_recent[$hierarchy]) {
                                $most_recent[$hierarchy] = $last_updated;
                            }
                            //Activity dates
                            $activity_dates = $activity->{"activity-date"};
                            //if (count($activity_dates) > 0) {
                            //if ($activity_dates !=NULL) {
                            //  $activities_with_at_least_one[$hierarchy]++;
                            //}
                            foreach ($activity_dates as $activity_date) {
                                //$attributes = array("end-actual","end-planned","start-actual","start-planned");
                                // $no_activity_dates[$hierarchy]++;
                                //foreach($attributes as $attribute) {
                                $type = (string) $activity_date->attributes()->type;
                                if ($type == "start-actual" || $type == "start-planned") {
                                    $type = "start";
                                }
                                if ($type == "end-actual" || $type == "end-planned") {
                                    $type = "end";
                                }
                                //$date = (string)$activity_date->attributes()->{'iso-date'};
                                //Special Case for DFID
                                //$date = (string)$activity_date;
                                //echo $date; die;
                                // $unix_time = strtotime($date);
                                //if ($unix_time) {
                                //  $year = date("Y",strtotime($date));
                                //} else {
                                //   $year = 0; //we could not parse the date, so store the year as 0
                                //// }
                                //$activity_by[$year][$hierarchy][$type]++;
                                $activities_with_attribute[$hierarchy][$type][] = (string) $activity->{'iati-identifier'};
                                //Languages
                                // if($hierarchy == 2) {
                                $title_langs = $country_langs = $description_langs = $all_langs = array();
                                //Reset each of these each run through
                                //Find default language of the activity
                                $default_lang = (string) $activity->attributes('http://www.w3.org/XML/1998/namespace')->{'lang'};
                                //echo $default_lang;
                                //Find recipient countries for this activity:
                                $recipient_countries = $activity->{"recipient-country"};
                                foreach ($recipient_countries as $country) {
                                    $code = (string) $country->attributes()->code;
                                    //Look up default language for this code:
                                    $country_langs[] = look_up_lang($code);
                                }
                                //print_r($country_langs);
                                //Find all the different languages used on the title element
                                $titles = $activity->title;
                                foreach ($titles as $title) {
                                    //create an array of all declared languages on titles
                                    $title_lang = (string) $title->attributes('http://www.w3.org/XML/1998/namespace')->{'lang'};
                                    if ($title_lang == NULL) {
                                        $title_langs[] = $default_lang;
                                    } else {
                                        $title_langs[] = $title_lang;
                                    }
                                    $title_lang = "";
                                }
                                //Find all the different languages used on the description element
                                $descriptions = $activity->description;
                                foreach ($descriptions as $description) {
                                    //create an array of all declared languages on titles
                                    $description_lang = (string) $description->attributes('http://www.w3.org/XML/1998/namespace')->{'lang'};
                                    if ($description_lang == NULL) {
                                        $description_langs[] = $default_lang;
                                    } else {
                                        $description_langs[] = $description_lang;
                                    }
                                    $description_lang = "";
                                }
                                //print_r($title_langs);
                                //die;
                                //Merge these arrays
                                $all_langs = array_merge($description_langs, $title_langs);
                                $all_langs = array_unique($all_langs);
                                //Loop through the country languiages and see if they are found on either the title or description
                                foreach ($country_langs as $lang) {
                                    if (in_array($lang, $all_langs)) {
                                        $activies_in_country_lang[$hierarchy][] = (string) $activity->{'iati-identifier'};
                                    }
                                }
                                //$description_lang = (string)$activity->description->attributes('http://www.w3.org/XML/1998/namespace')->{'lang'};
                                // }
                            }
                        }
                        //end foreach
                    }
                    //end if not organisation file
                }
                //end if xml is created
            }
            // end if file is not a system file
        }
        //end while
        closedir($handle);
    }
    //if (isset($types)) {
    //echo "no_activities" . PHP_EOL;
    //print_r($no_activities);
    //echo "activities_with_at_least_one" . PHP_EOL;
    //print_r($activities_with_at_least_one);
    //echo "no_activity_dates" . PHP_EOL;
    //print_r($no_activity_dates);
    //echo "activity_by_year" . PHP_EOL;
    ksort($activity_by);
    //print_r($activity_by);
    //echo "activities_with_attribute" . PHP_EOL;
    //print_r($activities_with_attribute);
    //foreach($types as $attribute_name=>$attribute) {
    ///  echo $attribute_name;
    //foreach($attribute as $hierarchy=>$values) {
    //   echo $hierarchy;
    //   print_r(array_count_values($values));
    // }
    // }
    //echo count($participating_org_implementing[0]); die;
    $found_hierarchies = array_unique($found_hierarchies);
    sort($found_hierarchies);
    //die;
    return array("no-activities" => $no_activities, "activities_with_at_least_one" => $activities_with_at_least_one, "no_activity_dates" => $no_activity_dates, "activity_by_year" => $activity_by, "hierarchies" => array_unique($found_hierarchies), "activities_with_attribute" => $activities_with_attribute, "document_links" => $document_links, "result_element" => $result_element, "conditions" => $conditions, "participating_org_accountable" => $participating_org_accountable, "participating_org_implementing" => $participating_org_implementing, "budget" => $budget, "identifiers" => $identifiers, "transaction_type_commitment" => $transaction_type_commitment, "transaction_type_disbursement" => $transaction_type_disbursement, "transaction_type_expenditure" => $transaction_type_expenditure, "no_disbursements" => $no_disbursements, "no_tracable_transactions" => $no_tracable_transactions, "no_incoming_funds" => $no_incoming_funds, "activities_with_location" => $activities_with_location, "activities_with_coordinates" => $activities_with_coordinates, "activities_with_adminstrative" => $activities_with_adminstrative, "activities_sector_assumed_dac" => $activities_sector_assumed_dac, "activities_sector_declared_dac" => $activities_sector_declared_dac, "most_recent" => $most_recent, "activies_in_country_lang" => $activies_in_country_lang);
    //} else {
    //  return FALSE;
    //}
}
コード例 #21
0
ファイル: Config.php プロジェクト: asad345100/pos-ci
 function base_img($uri = '')
 {
     return $this->slash_item('base_img') . ltrim($this->_uri - string($uri), '/');
 }
コード例 #22
0
 public function tease()
 {
     return string($this->entity->text)->tease();
 }
コード例 #23
0
 /**
  * Get the directory where all files of the media item are stored.
  *
  * @return string
  */
 protected function getBaseMediaDirectory()
 {
     $baseDirectory = string($this->getStoragePath())->replace(public_path(), '');
     return $baseDirectory;
 }
コード例 #24
0
ファイル: ToUpperTest.php プロジェクト: sidis405/area.dev
 /**
  * @test
  */
 public function it_is_chainable()
 {
     $this->assertInstanceOf(\Spatie\String\Str::class, string('test')->toUpper());
 }
コード例 #25
0
 /**
  * @param string $pdfFile
  *
  * @return string
  */
 protected function convertToImage($pdfFile)
 {
     $imageFile = string($pdfFile)->pop('.') . '.jpg';
     (new Pdf($pdfFile))->saveImage($imageFile);
     return $imageFile;
 }
コード例 #26
0
ファイル: PossessiveTest.php プロジェクト: sidis405/area.dev
 /**
  * @test
  */
 public function it_is_chainable()
 {
     $this->assertInstanceOf(\Spatie\String\Str::class, string('Bob')->possessive());
 }
コード例 #27
0
ファイル: api.php プロジェクト: ZerGabriel/friendica
function api_statusnet_config(&$a, $type)
{
    $name = $a->config['sitename'];
    $server = $a->get_hostname();
    $logo = $a->get_baseurl() . '/images/friendica-64.png';
    $email = $a->config['admin_email'];
    $closed = $a->config['register_policy'] == REGISTER_CLOSED ? 'true' : 'false';
    $private = $a->config['system']['block_public'] ? 'true' : 'false';
    $textlimit = (string) ($a->config['max_import_size'] ? $a->config['max_import_size'] : 200000);
    if ($a->config['api_import_size']) {
        $texlimit = string($a->config['api_import_size']);
    }
    $ssl = $a->config['system']['have_ssl'] ? 'true' : 'false';
    $sslserver = $ssl === 'true' ? str_replace('http:', 'https:', $a->get_baseurl()) : '';
    $config = array('site' => array('name' => $name, 'server' => $server, 'theme' => 'default', 'path' => '', 'logo' => $logo, 'fancy' => true, 'language' => 'en', 'email' => $email, 'broughtby' => '', 'broughtbyurl' => '', 'timezone' => 'UTC', 'closed' => $closed, 'inviteonly' => false, 'private' => $private, 'textlimit' => $textlimit, 'sslserver' => $sslserver, 'ssl' => $ssl, 'shorturllength' => '30', 'friendica' => array('FRIENDICA_PLATFORM' => FRIENDICA_PLATFORM, 'FRIENDICA_VERSION' => FRIENDICA_VERSION, 'DFRN_PROTOCOL_VERSION' => DFRN_PROTOCOL_VERSION, 'DB_UPDATE_VERSION' => DB_UPDATE_VERSION)));
    return api_apply_template('config', $type, array('$config' => $config));
}
コード例 #28
0
 public function getExcerptAttribute($length = 200) : Str
 {
     return string($this->text)->tease($length);
 }
コード例 #29
0
ファイル: api.php プロジェクト: msooon/hubzilla
function api_statusnet_config(&$a, $type)
{
    load_config('system');
    $name = get_config('system', 'sitename');
    $server = $a->get_hostname();
    $logo = $a->get_baseurl() . '/images/rm-64.png';
    $email = get_config('system', 'admin_email');
    $closed = get_config('system', 'register_policy') == REGISTER_CLOSED ? 'true' : 'false';
    $private = get_config('system', 'block_public') ? 'true' : 'false';
    $textlimit = (string) (get_config('system', 'max_import_size') ? get_config('system', 'max_import_size') : 200000);
    if (get_config('system', 'api_import_size')) {
        $texlimit = string(get_config('system', 'api_import_size'));
    }
    $ssl = get_config('system', 'have_ssl') ? 'true' : 'false';
    $sslserver = $ssl === 'true' ? str_replace('http:', 'https:', $a->get_baseurl()) : '';
    $config = array('site' => array('name' => $name, 'server' => $server, 'theme' => 'default', 'path' => '', 'logo' => $logo, 'fancy' => 'true', 'language' => 'en', 'email' => $email, 'broughtby' => '', 'broughtbyurl' => '', 'timezone' => 'UTC', 'closed' => $closed, 'inviteonly' => 'false', 'private' => $private, 'textlimit' => $textlimit, 'sslserver' => $sslserver, 'ssl' => $ssl, 'shorturllength' => '30', 'hubzilla' => array('PLATFORM_NAME' => PLATFORM_NAME, 'RED_VERSION' => RED_VERSION, 'ZOT_REVISION' => ZOT_REVISION, 'DB_UPDATE_VERSION' => DB_UPDATE_VERSION)));
    return api_apply_template('config', $type, array('$config' => $config));
}
コード例 #30
0
ファイル: db.php プロジェクト: LupusMichaelis/horn
 public function is_scheme_supported(h\string $candidate)
 {
     return \string('mysql')->is_equal($candidate);
 }