Example #1
0
 public static function createStyleSheetLink($src)
 {
     $instance = new self();
     $instance->setAttribute("rel", "stylesheet");
     $instance->setAttribute("type", "text/css");
     $instance->setAttribute("href", $src);
     return $instance;
 }
Example #2
0
 public static function create(array $config)
 {
     $connection = new self($config['dsn'], $config['user'], $config['pass'], $config['connection_options']);
     $connection->config = $config;
     $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $connection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
     // TODO: can we make this optional ?
     return $connection;
 }
 /**
  * Register NotTranslatableSelectBox
  * @param  string $control_name string
  * @return void
  */
 public static function register($control_name = 'addNotTranslatableSelect')
 {
     Nette\Object::extensionMethod('Nette\\Forms\\Container::' . $control_name, function ($form, $name, $label = NULL, array $items = NULL, $size = NULL) {
         $control = new self($label, $items);
         if ($size > 1) {
             $control->setAttribute('size', (int) $size);
         }
         return $form[$name] = $control;
     });
 }
    /**
     * @param int $lowestGlobalRanking
     * @param int $applicationId
     * @param bool $localQuiz
     * @return QuizPendingRankingUpdate
     */
    static function add( $lowestGlobalRanking, $applicationId, $localQuiz )
    {
        $clusterIdentifier = ($localQuiz) ? ClusterTool::clusterIdentifier() : '';
        $qpru = self::fetchObject( self::definition(), null, array(
            'cluster_identifier' => $clusterIdentifier,
            'application_id'     => $applicationId
        ) );
        if( !$qpru )
            $qpru = new self();
        else {
            if( (int)$qpru->attribute( 'lowest_global_ranking' ) > $lowestGlobalRanking )
                return false;
        }
        $qpru->setAttribute( 'lowest_global_ranking', $lowestGlobalRanking );
        $qpru->setAttribute( 'cluster_identifier', $clusterIdentifier );
        $qpru->setAttribute( 'application_id', $applicationId );
        $qpru->store();

        return $qpru;
    }
Example #5
0
 /**
  * Processa i dati
  * @param type $data
  */
 public function process($data)
 {
     foreach ($data as $nodeName => $nodeValue) {
         // $nodeValue è sempre un oggetto
         if ($nodeValue->count() > 0 || count($nodeValue->attributes()) > 0) {
             // se ha figli o ha attributi, allora lo considero come oggetto da parsare
             // se ha attributi li metto in $_attributes
             $clone = new self();
             $clone->process($nodeValue);
             foreach ($nodeValue->attributes() as $attrName => $attrValue) {
                 $clone->setAttribute($attrName, $attrValue);
             }
             $this->{$nodeName} = $clone;
         } else {
             // altrimenti è una stringa
             $this->{$nodeName} = (string) $nodeValue;
         }
     }
 }
Example #6
0
 /**
  * Factory method to create a new detached Zend_Ldap_Node for a given DN.
  *
  * @param  string|array|Zend_Ldap_Dn $dn
  * @param  array                     $objectClass
  * @return Zend_Ldap_Node
  * @throws Zend_Ldap_Exception
  */
 public static function create($dn, array $objectClass = array())
 {
     if (is_string($dn) || is_array($dn)) {
         $dn = Zend_Ldap_Dn::factory($dn);
     } else {
         if ($dn instanceof Zend_Ldap_Dn) {
             $dn = clone $dn;
         } else {
             /**
              * @see Zend_Ldap_Exception
              */
             require_once PHP_LIBRARY_PATH . 'Zend/Ldap/Exception.php';
             throw new Zend_Ldap_Exception(null, '$dn is of a wrong data type.');
         }
     }
     $new = new self($dn, array(), false, null);
     $new->_ensureRdnAttributeValues();
     $new->setAttribute('objectClass', $objectClass);
     return $new;
 }
 /**
  * @param int $quizId
  * @param string $clusterIdentifier
  * @param int $applicationId
  * @param int $points
  * @param int $correctAnswer
  */
 static function add( $quizId, $clusterIdentifier, $applicationId, $points, $correctAnswer )
 {
     $quizMeta = self::fetchObject( self::definition(), null, array( 'quiz_id' => $quizId, 'cluster_identifier' => $clusterIdentifier ) );
     if( !$quizMeta )
     {
         $quizMeta = new self();
         $quizMeta->setAttribute( 'quiz_id', $quizId );
     }
     $quizMeta->setAttribute( 'cluster_identifier', $clusterIdentifier );
     $quizMeta->setAttribute( 'application_id', $applicationId );
     $quizMeta->setAttribute( 'points', $points );
     $quizMeta->setAttribute( 'correct_answer', $correctAnswer );
     $quizMeta->store();
 }
Example #8
0
 /**
  * Factory method to create a new detached Zend\Ldap\Node for a given DN.
  *
  * @param  string|array|Dn $dn
  * @param  array           $objectClass
  * @return Node
  * @throws Exception\LdapException
  */
 public static function create($dn, array $objectClass = array())
 {
     if (is_string($dn) || is_array($dn)) {
         $dn = Dn::factory($dn);
     } elseif ($dn instanceof Dn) {
         $dn = clone $dn;
     } else {
         throw new Exception\LdapException(null, '$dn is of a wrong data type.');
     }
     $new = new self($dn, array(), false, null);
     $new->ensureRdnAttributeValues();
     $new->setAttribute('objectClass', $objectClass);
     return $new;
 }
    /**
     * @param string $content
     * @return array
     */
    static function add( $content )
    {
        $currentMMUser = MMUsers::getCurrentUserObject();
        if( !$currentMMUser )
            return false;

        $prcuh = self::fetchObject( self::definition(), null, array( 'md5_uuid' => md5( $currentMMUser->attribute( 'uuid' ) ) ) );
        if( !$prcuh )
        {
            $prcuh = new self();
            $prcuh->setAttribute( 'md5_uuid', md5( $currentMMUser->attribute( 'uuid' ) ) );
        }
        if( $prcuh && $content != 'undefined' )
        {
            $prcuh->setAttribute( 'content', $content );
        }
        $prcuh->store();

        return array( 'token' => $prcuh->attribute( 'md5_uuid' ) );
    }
 /**
  * Creates SK ITC Bundle DTD Attribute List
  *
  * @param string $source
  *        	SK ITC Bundle DTD Attribute List Source
  * @return \SK\ITCBundle\ORM\DTD\AttributeList
  */
 public static function create($source, Document $document)
 {
     $entity = null;
     $sourceAttributes = explode(" ", $source);
     $instance = new self($source);
     $entity = array_shift($sourceAttributes);
     $j = 0;
     for ($i = 0; $i < count($sourceAttributes); $i++) {
         $sourceAttribute = $sourceAttributes[$i];
         if (preg_match("/%/", $sourceAttribute) && $j == 0) {
             $j = $j + 2;
             $attribute = new Attribute("");
             $instance->setAttribute($attribute);
         } else {
             $column = $j % 3;
             switch ($column) {
                 case 0:
                     $attributeName = $sourceAttribute;
                     ++$j;
                     break;
                 case 1:
                     $attributeEntity = $sourceAttribute;
                     ++$j;
                     break;
                 case 2:
                     $attributeDefaultValue = $sourceAttribute;
                     $attribute = new Attribute("");
                     $attribute->setDocument($document);
                     $attribute->setName($attributeName);
                     $attribute->setEntity($document->getEntity($attributeEntity));
                     $attribute->setDefaultValue($attributeDefaultValue);
                     $instance->setAttribute($attribute);
                     $j = 0;
                     break;
             }
         }
     }
     return $instance;
 }