コード例 #1
0
 public static function init(\MUtil_Html_Creator $creator = null)
 {
     if (null === $creator) {
         $creator = \MUtil_Html::getCreator();
     }
     // \MUtil_Html::$verbose = true;
     // Set the image directories
     \MUtil_Html_ImgElement::addImageDir('gems/images');
     \MUtil_Html_ImgElement::addImageDir('gems/icons');
     $escort = \GemsEscort::getInstance();
     if (isset($escort->project->imagedir)) {
         \MUtil_Html_ImgElement::addImageDir($escort->project->imagedir);
     }
     // Gems specific element functions
     $creator->addElementFunction('actionDisabled', array(__CLASS__, 'actionDisabled'), 'actionLink', array(__CLASS__, 'actionLink'), 'buttonDiv', array(__CLASS__, 'buttonDiv'), 'pagePanel', array(__CLASS__, 'pagePanel'), 'pInfo', array(__CLASS__, 'pInfo'), 'smallData', array(__CLASS__, 'smallData'));
     // \Gems_Util::callProjectClass('Html', 'init', $creator);
     // Allow in-project overruling
     $projectFile = APPLICATION_PATH . '/classes/' . GEMS_PROJECT_NAME_UC . '/Html.php';
     if (file_exists($projectFile)) {
         include_once $projectFile;
         call_user_func(array(GEMS_PROJECT_NAME_UC . '_Html', 'init'), $creator);
     }
     // */
     return $creator;
 }
コード例 #2
0
 /**
  * Returns a list of available icons under 'htdocs/pulse/icons'
  * @return string[]
  */
 protected function _getAvailableIcons()
 {
     $icons = array();
     $iterator = new DirectoryIterator(realpath(GEMS_WEB_DIR . '/gems/icons'));
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->isFile()) {
             // $icons[$fileinfo->getFilename()] = $fileinfo->getFilename();
             $filename = $fileinfo->getFilename();
             $url = $this->view->baseUrl() . \MUtil_Html_ImgElement::getImageDir($filename);
             $icons[$fileinfo->getFilename()] = \MUtil_Html::create('span', $filename, array('style' => 'background: transparent url(' . $url . $filename . ') center right no-repeat; padding-right: 20px;'));
         }
     }
     return $icons;
 }
コード例 #3
0
 /**
  * Adds columns from the model to the bridge that creates the browse table.
  *
  * Overrule this function to add different columns to the browse table, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_TableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @return void
  */
 protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $tUtil = $this->util->getTokenData();
     $table = $bridge->getTable();
     $table->appendAttrib('class', 'compliance');
     $thead = $table->thead();
     $th_row = $thead->tr(array('class' => 'rounds'));
     $th = $th_row->td();
     $span = 1;
     $cRound = null;
     $cDesc = null;
     $thead->tr();
     if ($showMenuItem = $this->getShowMenuItem()) {
         $bridge->addItemLink($showMenuItem->toActionLinkLower($this->request, $bridge));
     }
     // Initialize alter
     $alternateClass = new \MUtil_Lazy_Alternate(array('odd', 'even'));
     foreach ($model->getItemsOrdered() as $name) {
         if ($label = $model->get($name, 'label')) {
             $round = $model->get($name, 'round');
             if ($round == $cRound) {
                 $span++;
                 $class = null;
             } else {
                 // If the round has an icon, show the icon else just 'R' since
                 // complete round description messes up the display
                 $th->append($cDesc);
                 $th->title = $cRound;
                 $th->colspan = $span;
                 $span = 1;
                 $cRound = $round;
                 if ($cIcon = $model->get($name, 'roundIcon')) {
                     $cDesc = \MUtil_Html_ImgElement::imgFile($cIcon, array('alt' => $cRound, 'title' => $cRound));
                 } else {
                     if (substr($name, 0, 5) == 'stat_') {
                         $cDesc = 'R';
                     } else {
                         $cDesc = null;
                     }
                 }
                 $class = 'newRound';
                 $thClass = $class . ' ' . $alternateClass;
                 // Add alternate class only for th
                 $th = $th_row->td(array('class' => $thClass));
             }
             if ($model->get($name, 'noSort')) {
                 $title = array(\MUtil_Lazy::method($tUtil, 'getStatusDescription', $bridge->{$name}), "\n" . $model->get($name, 'description'));
                 $token = 'tok_' . substr($name, 5);
                 $href = new \MUtil_Html_HrefArrayAttribute(array($this->request->getControllerKey() => 'track', $this->request->getActionKey() => 'show', \MUtil_Model::REQUEST_ID => $bridge->{$token}));
                 $href->setRouteReset();
                 $onclick = new \MUtil_Html_OnClickArrayAttribute();
                 $onclick->addUrl($href)->addCancelBubble();
                 $tds = $bridge->addColumn(array(\MUtil_Html_AElement::iflink($bridge->{$token}, array($href, 'onclick' => 'event.cancelBubble = true;', 'title' => $title, $bridge->{$name}), $bridge->{$name}), 'class' => array('round', \MUtil_Lazy::method($tUtil, 'getStatusClass', $bridge->{$name})), 'title' => $title, 'onclick' => \MUtil_Lazy::iff($bridge->{$token}, $onclick)), array($label, 'title' => $model->get($name, 'description'), 'class' => 'round'));
             } else {
                 $tds = $bridge->addSortable($name, $label);
             }
             if ($class) {
                 $tds->appendAttrib('class', $class);
             }
         }
     }
     $th->append($cRound);
     $th->colspan = $span;
 }
コード例 #4
0
ファイル: ImgElement.php プロジェクト: GemsTracker/MUtil
 /**
  * Use this function to set the web root directory if your application uses chdir() anywhere.
  *
  * @param string $webRoot The current webroot
  */
 public static function setWebRoot($webRoot)
 {
     self::$_webRoot = $webRoot;
 }
コード例 #5
0
 public function formatImg($value, $new, $name, array $context = array())
 {
     // TODO: Find a way to build an url that identifies the form so we can download the attachted image
     //       and still check if one is logged in
     if (!empty($value)) {
         return \MUtil_Html_ImgElement::img(array('src' => array('controller' => 'openrosa', 'action' => 'image', 'id' => $this->formID, 'version' => $this->formVersion, 'resp' => $context['orf_id'], 'field' => str_replace('.', '_', $value)), 'width' => '350px;'));
     } else {
         return $value;
     }
 }