Пример #1
0
 /**
  * Adds an item
  * 
  * @param double $value
  * @param string $label
  * 
  * @throws \Exception if $value doesn't validate
  * @throws \Exception if $label doesn't validate
  * 
  * @return \sfAltumoPlugin\Geckoboard\Widget\FunnelWidget 
  */
 public function addItem($value, $label)
 {
     $value = \Altumo\Validation\Numerics::assertDouble($value);
     $label = \Altumo\Validation\Strings::assertString($label);
     $item = new \stdClass();
     $item->value = $value;
     $item->label = $label;
     $this->items[] = $item;
     return $this;
 }
Пример #2
0
 /**
  * 
  * @param string $text
  * @param int $type
  * 
  * @throws \Exception if maximum number of items reached
  * 
  * @return \sfAltumoPlugin\Geckoboard\Widget\TextWidget
  */
 public function addItem($text, $type = self::TYPE_NONE)
 {
     $item = new \stdClass();
     // pre-validate and set text
     $item->text = \Altumo\Validation\Strings::assertString($text);
     // pre-validate and set type
     $item->type = \Altumo\Validation\Numerics::assertInteger($type);
     if (count($this->getItems()) > self::MAXIMUM_ITEM_COUNT - 1) {
         throw new \Exception("Cannot add new item, maximum count reached");
     }
     // add to items
     $this->items[] = $item;
     return $this;
 }
 /**
  * @param string $v
  *
  * @return \sfAltumoPlugin\Geckoboard\Widget\NumberAndSecondaryStatWidget
  *
  * @throws \Exception if value doesn't validate
  */
 public function setSecondaryText($v)
 {
     $this->secondary_text = \Altumo\Validation\Strings::assertString($v);
     return $this;
 }
Пример #4
0
 /**
  * Set the content of this Message from a string, or add a content part
  * in a different format.
  * 
  * E.g. if also using setContent(), this could be used to add a third part
  * in 'text/json' if you wanted to do that. Otherwise, it can be used without
  * setContent() in order to send emails without using partials.
  * 
  * 
  * @param string $content
  * @param array $encoding   //content encoding. e.g. text/html, text/plain, etc.
  * 
  * @return \sfAltumoPlugin\Email\Message
  */
 public function setContentString($content, $encoding = 'text/plain')
 {
     $content = \Altumo\Validation\Strings::assertString($content, 'Invalid email content. String expected.');
     $encoding = \Altumo\Validation\Strings::assertString($encoding, 'Invalid email content encoding. String expected.');
     $this->content_parts[] = array($content, $encoding);
     return $this;
 }
Пример #5
0
 /**
  * Sets the subject of this TextMessage
  * 
  * 
  * @param string $subject
  * 
  * @return \sfAltumoPlugin\Phone\TextMessage
  */
 public function setText($text)
 {
     $this->text = \Altumo\Validation\Strings::assertString($text);
     return $this;
 }
Пример #6
0
 /**
  * Starts a CMS fragment by using output buffering. It will also create a new model and save it if it doesn't exist.
  *
  * @param $tag
  *  // tag is a unique identifier for a given fragment
  *
  * @param string $chrome_attributes
  *  // attributes of the element that wraps the fragment. This will just be added to the element's definition.
  *
  * @throws \Exception
  *
  * @return void
  */
 public function startCmsFragment($tag, $chrome_attributes = '', $fragment_type = 'text')
 {
     $chrome_attributes = \Altumo\Validation\Strings::assertString($chrome_attributes, '$chrome_attributes expects a string');
     // prevent nested fragments
     if ($this->hasCurrentCmsFragment()) {
         throw new \Exception('Already inside "' . $this->getCurrentCmsFragment()->getTag() . '". Cannot start another fragment.');
     }
     // retrieve fragment
     $fragment = \CmsFragmentPeer::retrieveByTag($tag);
     // if this is a new segment, create a new one.
     if (is_null($fragment)) {
         $fragment = \CmsFragmentPeer::getStubCmsFragment($tag, $fragment_type);
     }
     // set chrome attributes
     $fragment->setChromeAttributes($chrome_attributes);
     // set current fragment
     $this->setCurrentCmsFragment($fragment);
     // start output buffering
     ob_start();
     $this->cms_buffer_count++;
 }
Пример #7
0
 /**
  * Setter for the collection_namespace field on this PivotalTrackerPackage.
  * 
  * @param string $collection_namespace
  * @throws \Exception //if $collection_namespace is not a string
  */
 public function setCollectionNamespace($collection_namespace)
 {
     $collection_namespace = \Altumo\Validation\Strings::assertString($collection_namespace);
     $this->collection_namespace = $collection_namespace;
 }
Пример #8
0
 /**
  * @param string $v
  * 
  * @throws \Exception if $v doesn't validate
  * 
  * @return \sfAltumoPlugin\Geckoboard\Widget\NumberAndSecondaryStatWidget
  */
 public function setMaxText($v)
 {
     $this->max_text = is_null($v) ? $v : \Altumo\Validation\Strings::assertString($v, 'Max text expects a string');
     return $this;
 }
Пример #9
0
 /**
  * @param string $descriptor
  * 
  * @return \sfAltumoPlugin\Geckoboard\Widget\LineChartWidget
  * 
  * @throws \Exception if descriptor fails to validate
  */
 public function addAxisYDescriptor($descriptor)
 {
     $this->axis_y_descriptors[] = \Altumo\Validation\Strings::assertString($descriptor);
     return $this;
 }
Пример #10
0
 /**
  * Removes all non-alphabetic characters from the given string.
  * 
  * @throws \Exception                    //if string is not a string
  * @param string $string
  */
 public static function stripNonAlphaCharacters($string)
 {
     \Altumo\Validation\Strings::assertString($string);
     return preg_replace('/[^a-zA-Z]/', '', $string);
 }