Example #1
0
 public function testCanPassCustomTable()
 {
     $table = new Table();
     $table['%'] = '001100110011';
     $text = new Text($table);
     $this->assertSame('AVSLAG -30%', $text->fromMorse($text->toMorse('Avslag -30%')));
 }
Example #2
0
 /**
  * Standard-Angezeige.
  *
  * ist ein Content definiert, wird dieser ebenfalls mit angegeben.   
  */
 function show()
 {
     echo "<a name='" . $this->NAME . "' ";
     if ($this->XPOS > 0 && $this->YPOS > 0) {
         echo " style=\"  position:absolute; top:" . $this->YPOS . "px; left:" . $this->XPOS . "px; \" ";
     }
     if ($this->XPOS < 0 && $this->YPOS > 0) {
         echo " style=\"  position:absolute; top:" . $this->YPOS . "px; right:" . $this->XPOS * -1 . "px; \" ";
     }
     if ($this->XPOS < 0 && $this->YPOS < 0) {
         echo " style=\"  position:absolute; bottom:" . $this->YPOS * -1 . "px; right:" . $this->XPOS * -1 . "px; \" ";
     }
     if ($this->XPOS > 0 && $this->YPOS < 0) {
         echo " style=\"  position:absolute; bottom:" . $this->YPOS * -1 . "px; left:" . $this->XPOS . "px; \" ";
     }
     echo $this->getToolTipTag() . ">";
     if (get_class($this->TEXT) && method_exists($this->TEXT, "show")) {
         $this->TEXT->show();
     } else {
         $t = new Text($this->TEXT);
         $t->setFilter(false);
         $t->show();
     }
     echo "</a>";
 }
Example #3
0
	function FeedItems() {
		$output = new DataObjectSet();
		
		include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/SimplePie.php'));
		
		$t1 = microtime(true);
		$this->feed = new SimplePie($this->AbsoluteRssUrl, TEMP_FOLDER);
		$this->feed->init();
		if($items = $this->feed->get_items(0, $this->NumberToShow)) {
			foreach($items as $item) {
				
				// Cast the Date
				$date = new Date('Date');
				$date->setValue($item->get_date());

				// Cast the Title
				$title = new Text('Title');
				$title->setValue($item->get_title());

				$output->push(new ArrayData(array(
					'Title' => $title,
					'Date' => $date,
					'Link' => $item->get_link()
				)));
			}
			return $output;
		}
	}
 public function testGetNextEol()
 {
     $text = new Text("\n");
     $this->assertEquals(0, $text->getNextEol());
     $text = new Text("roman");
     $this->assertEquals(4, $text->getNextEol());
 }
Example #5
0
 public function testCompile()
 {
     $field = new Text("test", "Test");
     $expected = "Test";
     $value = $field->compile();
     $this->assertEquals($expected, $value);
 }
 public function getComponent($value, $cellFont, $row, $column)
 {
     $text = new Text();
     $text->setFont($cellFont);
     $text->value = $value;
     return $text;
 }
 /**
  * Gets a list of all the items in the RSS feed given a user-provided URL, limit, and date format
  *
  * @return ArrayList
  */
 public function RSSItems()
 {
     if (!$this->FeedURL) {
         return false;
     }
     $doc = new DOMDocument();
     @$doc->load($this->FeedURL);
     $items = $doc->getElementsByTagName('item');
     $feeds = array();
     foreach ($items as $node) {
         $itemRSS = array('title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue);
         $feeds[] = $itemRSS;
     }
     $output = ArrayList::create(array());
     $count = 0;
     foreach ($feeds as $item) {
         if ($count >= $this->Count) {
             break;
         }
         // Cast the Date
         $date = new Date('Date');
         $date->setValue($item['date']);
         // Cast the Title
         $title = new Text('Title');
         $title->setValue($item['title']);
         $output->push(new ArrayData(array('Title' => $title, 'Date' => $date->Format($this->DateFormat), 'Link' => $item['link'])));
         $count++;
     }
     return $output;
 }
Example #8
0
 public function testPlacementAppend()
 {
     $decorator = new Text('foo');
     $decorator->setOption('placement', 'append');
     $expected = 'barfoo';
     $actual = $decorator->render('bar');
     $this->assertSame($expected, $actual);
 }
Example #9
0
 public static function init($name, $value, $attrs = null)
 {
     $t = new Text($name, $value);
     if ($attrs) {
         $t->add_attrs($attrs);
     }
     return $t;
 }
Example #10
0
 /**
  * Test {@link Text->LimitWordCountXML()}
  */
 function testLimitWordCountXML()
 {
     $cases = array('<p>Stuff & stuff</p>' => 'Stuff &amp;...', "Stuff\nBlah Blah Blah" => "Stuff<br />Blah Blah...", "Stuff<Blah Blah" => "Stuff&lt;Blah Blah", "Stuff>Blah Blah" => "Stuff&gt;Blah Blah");
     foreach ($cases as $originalValue => $expectedValue) {
         $textObj = new Text('Test');
         $textObj->setValue($originalValue);
         $this->assertEquals($expectedValue, $textObj->LimitWordCountXML(3));
     }
 }
Example #11
0
 public function testStrikeThrough()
 {
     // Arrange
     $text = new Text('Some italic text.', Text::STRIKETHROUGH);
     // Act
     $content = $text->toMarkDown();
     // Assert
     $this->assertSame('--Some italic text.-- ', $content);
 }
 public static function fromString(Text $configString)
 {
     $text = '';
     while (false === $configString->eof() && false === $configString->eol()) {
         $text .= $configString->getChar();
         $configString->inc();
     }
     return new Comment(ltrim($text, "# "));
 }
Example #13
0
 protected function writeText(Text $textChild, $level)
 {
     $newLine = $this->_pretty ? $this->_newLine : '';
     $indent = $this->_pretty ? str_repeat($this->_tabString, $level) : '';
     $text = $textChild->getText();
     //TODO: Need some kind of mb_wordwrap here, maybe:
     //http://stackoverflow.com/questions/3825226/multi-byte-safe-wordwrap-function-for-utf-8?
     return $this->_pretty && mb_strlen($text, 'utf-8') > $this->_textWrap ? $indent . wordwrap(str_replace("\n", '', $text), $this->_textWrap, "{$newLine}{$indent}") : $text;
 }
Example #14
0
 /**
  * Test {@link Text->LimitSentences()}
  */
 public function testLimitSentences()
 {
     $cases = array('' => '', 'First sentence.' => 'First sentence.', 'First sentence. Second sentence' => 'First sentence. Second sentence.', '<p>First sentence.</p>' => 'First sentence.', '<p>First sentence. Second sentence. Third sentence</p>' => 'First sentence. Second sentence.', '<p>First sentence. <em>Second sentence</em>. Third sentence</p>' => 'First sentence. Second sentence.', '<p>First sentence. <em class="dummyClass">Second sentence</em>. Third sentence</p>' => 'First sentence. Second sentence.');
     foreach ($cases as $originalValue => $expectedValue) {
         $textObj = new Text('Test');
         $textObj->setValue($originalValue);
         $this->assertEquals($expectedValue, $textObj->LimitSentences(2));
     }
 }
Example #15
0
 function showDescription()
 {
     $spc = new Spacer();
     $spc->show();
     $td = new Text("Beschreibung:", 2, true);
     $td->show();
     $d = new Text($this->getDescription());
     $d->show();
 }
Example #16
0
 /**
  *
  * Class constructor
  *
  * @param string $name
  *
  * @access public
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->setRepeating(true);
     $this->setSortable(true);
     $this->setLabel(Translate::translate('Gallery'));
     $name = new Text('name');
     $name->setLabel(Translate::translate('Name'));
     $this->addControl($name);
     $values = new Textarea('values');
     $values->setLabel(Translate::translate('Description'));
     $this->addControl($values);
 }
Example #17
0
 function show()
 {
     $t = new Table(array(""));
     $t->setAlign($this->getAlign());
     $r = $t->createRow();
     $r->setHeader(true);
     $txt = new Text($this->TEXT);
     $txt->setFonttype($this->FONTTYPE);
     $txt->setFilter($this->getFilter());
     $r->setAttribute(0, $txt);
     $t->addRow($r);
     $t->show();
 }
Example #18
0
 /**
  * @covers Xoops\Form\Text::render
  */
 public function testRender()
 {
     $value = $this->object->render();
     $this->assertTrue(is_string($value));
     $this->assertTrue(false !== strpos($value, '<input'));
     $this->assertTrue(false !== strpos($value, 'type="text"'));
     $this->assertTrue(false !== strpos($value, 'name="name"'));
     $this->assertTrue(false !== strpos($value, 'size="10"'));
     $this->assertTrue(false !== strpos($value, 'maxlength="20"'));
     $this->assertTrue(false !== strpos($value, 'placeholder="placeholder"'));
     $this->assertTrue(false !== strpos($value, 'title="Caption"'));
     $this->assertTrue(false !== strpos($value, 'id="name"'));
     $this->assertTrue(false !== strpos($value, 'value="value"'));
 }
Example #19
0
 public static function to_form(DefaultModel $dm)
 {
     $rc = new ReflectionClass(get_class($dm));
     $rm = $rc->getMethod("attrs");
     $attrs = $rm->invoke($dm, "");
     $at = explode(",", $attrs);
     for ($i = 0; $i < count($at); $i++) {
         $g = $rc->getMethod("get" . ucfirst($at[$i]));
         $f = new Text($at[$i], $g->invoke($dm, ""));
         echo "<div>";
         echo "<strong>" . $at[$i] . ": </strong>" . $f->to_s();
         echo "</div>\n";
     }
 }
function getTerminInfoForCalendarView($rowTermin)
{
    $ret = new Text("");
    if ($rowTermin['terminart'] == "angebot") {
        $res = $_SESSION['config']->DBCONNECT->executeQuery("SELECT * FROM stadt_angebot where terminserien_id =  " . $rowTermin['id']);
        $rowAngebot = mysql_fetch_array($res);
        if ($rowAngebot["kategorie"] != 99 && $rowAngebot["aktivjn"] == 'J') {
            $txt = new Text($rowAngebot['name'] . "<hr>");
            $txt->setFilter(false);
            $ret = new Link("?menuParent=Stadtplan&run=stadtplansuche&suchauswahlAnzeigen=" . $rowAngebot['id'] . "&suchauswahl=stadt_angebot", $txt);
            $ret->setToolTip("<b>" . $rowAngebot['name'] . "</b><br>" . $rowAngebot['text']);
        }
    }
    return $ret;
}
Example #21
0
 public static function process($action = 'list', $id = null)
 {
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST' && $action == 'edit') {
         // instancia
         $data = array('id' => $_POST['id'], 'name' => $_POST['name'], 'amount' => $_POST['amount']);
         if (WorthLib::save($data, $errors)) {
             $action = 'list';
             Message::Info(Text::_('Nivel de meritocracia modificado'));
             // Evento Feed
             $log = new Feed();
             $log->populate(Text::_('Nivel de meritocracia modificado'), '/admin/worth', \vsprintf("El admin %s ha %s el nivel de meritocrácia %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Modificado'), Feed::item('project', $icon->name))));
             $log->doAdmin('admin');
             unset($log);
         } else {
             Message::Error(Text::_('No se ha guardado correctamente. ') . implode('<br />', $errors));
             return new View('view/admin/index.html.php', array('folder' => 'worth', 'file' => 'edit', 'action' => 'edit', 'worth' => (object) $data));
         }
     }
     switch ($action) {
         case 'edit':
             $worth = WorthLib::getAdmin($id);
             return new View('view/admin/index.html.php', array('folder' => 'worth', 'file' => 'edit', 'action' => 'edit', 'worth' => $worth));
             break;
     }
     $worthcracy = WorthLib::getAll();
     return new View('view/admin/index.html.php', array('folder' => 'worth', 'file' => 'list', 'worthcracy' => $worthcracy));
 }
 public function getStdClass()
 {
     // init
     $result = new \stdClass();
     // action
     $result->id = $this->id;
     $result->person = $this->person->getStdClass();
     //        $result->name = html_entity_decode($this->name, ENT_COMPAT | ENT_HTML401, 'UTF-8');;
     //        $result->address = html_entity_decode($this->address, ENT_COMPAT | ENT_HTML401, 'UTF-8');
     $result->name = $this->name;
     $result->address = $this->address;
     $result->latitude = $this->latitude;
     $result->longitude = $this->longitude;
     $result->level = $this->level->getStdClass();
     $result->interpretationType = $this->interpretationType->getStdClass();
     $result->language = $this->language;
     $result->textCombined = $this->textCombined->getStdClass();
     $result->textHouseX = $this->textHouseX->getStdClass();
     $result->textHouseY = $this->textHouseY->getStdClass();
     $result->zodiacX = $this->zodiacX->getStdClass();
     $result->zodiacY = $this->zodiacY->getStdClass();
     $factorListStdClass = array();
     /** @var Factor $factor */
     foreach ($this->factors as $factor) {
         array_push($factorListStdClass, $factor->getStdClass());
     }
     $result->factors = $factorListStdClass;
     //        $result->code = html_entity_decode($this->code, ENT_COMPAT | ENT_HTML401, 'UTF-8');;
     $result->code = $this->code;
     $result->isPaid = $this->isPaid;
     $result->dateCreated = $this->dateCreated;
     // return
     return $result;
 }
Example #23
0
 static function init()
 {
     $version_file = APP_PATH . '/../version';
     if (file_exists($version_file)) {
         self::$version = trim(@file_get_contents($version_file));
     }
     $config_file = APP_PATH . '/config/config.php';
     if (!file_exists($config_file)) {
         throw new Exception("No config file");
     }
     $config = (include $config_file);
     self::$config = $config;
     self::$env = $config['env'];
     #self::$context = new stdClass();
     self::$context = new Context();
     Logger::init($config['logger']);
     if (isset($config['db'])) {
         Db::init($config['db']);
     }
     if (get_magic_quotes_gpc()) {
         foreach ($_GET as $k => $v) {
             $_GET[$k] = Text::stripslashes($v);
         }
         foreach ($_POST as $k => $v) {
             $_POST[$k] = Text::stripslashes($v);
         }
         foreach ($_COOKIE as $k => $v) {
             $_COOKIE[$k] = Text::stripslashes($v);
         }
     }
     $_REQUEST = $_GET + $_POST + $_COOKIE;
 }
Example #24
0
 protected function executeCreate(InputInterface $input, OutputInterface $output)
 {
     $client = $input->getOption('client');
     $name = $input->getOption('name');
     $secret = $input->getOption('secret');
     if (!$client) {
         // We can't use the generic `get_client()` for **creation**,
         // because we need to verify that the user does **not** exist.
         $clients = Arr::pluck(self::db_list(), 'id');
         $ask = function ($client) use($clients) {
             if (in_array($client, $clients)) {
                 throw new RuntimeException('Client "' . $client . '" already exists, try another name');
             }
             return $client;
         };
         $client = $this->getHelperSet()->get('dialog')->askAndValidate($output, 'Enter id of new client: ', $ask, FALSE);
     }
     if (!$name) {
         $name = $client;
     }
     if (!$secret) {
         $secret = Text::random('distinct', 24);
     }
     static::db_create(['id' => $client, 'secret' => $secret, 'name' => $name]);
     $input->setOption('client', $client);
     return $this->executeList($input, $output);
 }
Example #25
0
 public function __construct($name = null)
 {
     parent::__construct($name);
     $this->addTest('valid', function ($value) {
         return filter_var($value, FILTER_VALIDATE_EMAIL) && preg_match("/.*@.*\\..*/", $value);
     });
 }
Example #26
0
 public function _upload_image(Validate $array, $input)
 {
     if ($array->errors()) {
         // Don't bother uploading
         return;
     }
     // Get the image from the array
     $image = $array[$input];
     if (!Upload::valid($image) or !Upload::not_empty($image)) {
         // No need to do anything right now
         return;
     }
     if (Upload::valid($image) and Upload::type($image, $this->types)) {
         $filename = strtolower(Text::random('alnum', 20)) . '.jpg';
         if ($file = Upload::save($image, NULL, $this->directory)) {
             Image::factory($file)->resize($this->width, $this->height, $this->resize)->save($this->directory . $filename);
             // Update the image filename
             $array[$input] = $filename;
             // Delete the temporary file
             unlink($file);
         } else {
             $array->error('image', 'failed');
         }
     } else {
         $array->error('image', 'valid');
     }
 }
Example #27
0
 private function create_table($table_name)
 {
     $new_table = new Cms_Structure($table_name, TRUE);
     $default_params = Cms::get_default_table_params();
     $names_matching = Cms::get_names_matching();
     if (array_key_exists($table_name, $names_matching)) {
         $default_params['name'] = $names_matching[$table_name];
     } else {
         $default_params['name'] = str_replace('_', ' ', Text::ucfirst($new_table->get_alias()));
     }
     $default_column_config = Cms::get_default_column();
     $matching_rules = Cms::get_columns_matching_rules();
     $columns_data = Cms::get_dal_instance()->get_columns($new_table->get_table_name());
     $special_columns = Cms::get_special_columns();
     foreach ($special_columns as $param_name => $column_names) {
         if (array_key_exists($param_name, $default_params)) {
             foreach ($column_names as $col_name) {
                 if (array_key_exists($col_name, $columns_data)) {
                     $default_params[$param_name] = $col_name;
                 }
             }
         }
     }
     $new_table->set_options($default_params)->create_columns($columns_data, $matching_rules, $default_column_config)->save();
     return $new_table;
 }
Example #28
0
 public function value($value)
 {
     if ($value instanceof \DateTime) {
         $value = $value->format('Y-m-d');
     }
     return parent::value($value);
 }
Example #29
0
    /**
     * Draw the marker on the canvas
     * @param int $x The X (horizontal) position (in pixels) of the marker on the canvas 
     * @param int $y The Y (vertical) position (in pixels) of the marker on the canvas 
     * @param array $values The values representing the data the marker "points" to 
     * @access private
     */
    function _drawMarker($x, $y, $values = false)
    {
        parent::_drawMarker($x, $y, $values);

        $value = $this->_getDisplayValue($values);

        if ($this->_dataPreprocessor) {
            $value = $this->_dataPreprocessor->_process($value);
        }

        $this->_text = new Image_Graph_Text($x, $y, $value, $this->_font);
        $this->_text->setAlignment(IMAGE_GRAPH_ALIGN_CENTER);
        $this->add($this->_text);

        if ($this->_fillStyle) {
        	// Modified: Don't draw background
            //ImageFilledRectangle($this->_canvas(), $this->_fillLeft(), $this->_fillTop(), $this->_fillRight(), $this->_fillBottom(), $this->_getFillStyle());
        }

        if (isset($this->_borderStyle)) {            
        	// Modified: Don't draw a border
            //ImageRectangle($this->_canvas(), $this->_fillLeft(), $this->_fillTop(), $this->_fillRight(), $this->_fillBottom(), $this->_getBorderStyle());
        }

        $this->_text->_done();
    }
Example #30
0
 /**
  *
  */
 public function pagetexts()
 {
     // get the groups
     $texts = Text::all();
     // show the view and pass the group to it
     return View::make('pages.texts')->with('texts', $texts)->with('title', 'Sharon Hall Texts');
 }